Configuring commons logging in Glassfish
I am using commons logging for my application running on Glassfish V3.1(I am new to glassfish). I have different applications running on Glassfish under ../domain1 folder(Developers machine). I am using an XML to configure Logging.Following is the my xml config
<?xml version="1.0"开发者_运维知识库 encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
<appender name="file"
class="org.apache.log4j.RollingFileAppender">
<param name="maxFileSize" value="100KB" />
<param name="maxBackupIndex" value="5" />
<param name="File" value="/home/phanikumar/Desktop/debug.log" />
<param name="threshold" value="debug"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{DATE} %5p %c{1}:%L - %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="warn" />
<param name="LevelMax" value="fatal" />
</filter>
</appender>
<logger name="com">
<level value="DEBUG" />
<appender-ref ref="file"/>
</logger>
<root>
<appender-ref ref="file" />
</root>
</log4j:configuration>
In this config file I have explicitly mentioned the file to be in a specific location but it never did.Is there any problem with the logger file?Am I missing some thing?
or
Is there any way that I can configure my logs to be in a specific location? I have seen the server.log file and it is unsuitable for my requirement as the logs of all applications are logged in a same file.
Please kindly help me.
SOLUTION
Add a Properties file named commons-logging.properties in the class path.
And add the following property
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
This initializes Logging to Log4j Logger
Then it works perfectly.
EDIT:
Usually, by default commons logging searches for loggers like log4j. If the above solution doesnt work, one needs to check if the commons-logging jar file is corrupted i.e, check if the class files like org.apache.commons.logging.impl.Log4jLogger is present.
精彩评论