---
title: "设置第三方jar包的debug"
author: "dikar"
date: "2010-04-25T12:51:56Z"
tags: []
categories: ["编程语言"]
slug: "jar-debug"
draft: false
lastmod: "2011-05-13T20:54:20Z"
id: 652521
url: "https://dikar.iteye.com/blog/652521"
---

总是会遇到调试第三方jar包的问题，debug也好，打log也好都是一种方式，当然看第三方的jar包打debug日志是最好的，我不想为第三方jar配置一个log4J的xml，所以就在程序里实现下配置，这个很简单完全依赖log4J的加载方式，可以参见我上篇文章里。

 

补充下直接设置文件的

```
URL url = Thread.currentThread().getContextClassLoader().getResource("log4j.xml");
DOMConfigurator.configure(url);
```

 

 

好废话不说了。贴代码了。

 

```
Properties properties = new Properties();

properties.setProperty("log4j.rootLogger", "DEBUG,C");

properties.setProperty("log4j.appender.C",
"org.apache.log4j.ConsoleAppender");
	
properties.setProperty("log4j.appender.C.layout", "org.apache.log4j.PatternLayout");
	
PropertyConfigurator.configure(properties);
```