Monday, 15 February 2010

jsf - log statements are not going into mentioned log files -



jsf - log statements are not going into mentioned log files -

i have log4jconfig.xml shown below

<?xml version="1.0" encoding="utf-8" ?> <!doctype log4j:configuration scheme "log4j.dtd"> <log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="abclog4j" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/myapp/app/myserver/myproj/domains/logs/abclog.log"/> <param name="append" value="true"/> <param name="maxfilesize" value="5000kb"/> <param name="maxbackupindex" value="5"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> <logger name="com.mywhole.mysub.abc" additivity="false"> <level value="info"/> <appender-ref ref="abclog4j"/> </logger> <appender name="xyzlog4j" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/myapp/app/myserver/myproj/domains/logs/xyzlog.log"/> <param name="append" value="true"/> <param name="maxfilesize" value="5000kb"/> <param name="maxbackupindex" value="5"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> <logger name="com.mywhole.mysub.xyz" additivity="false"> <level value="info"/> <appender-ref ref="xyzlog4j"/> </logger> <appender name="stdout" class="org.apache.log4j.consoleappender"> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> ....................... <root> <priority value="error"/> <appender-ref ref="sysoutlog4j"/> </root> </log4j:configuration>

the probelm i'm facing log statements generated classes in com.mywhole.mysub.xyz going abclog.log , vice-versa. can explain me how solve issue

package com.mywhole.mysub.xyz.model; // import .... public class mybeackingbean extends mysuperbb{ public static final loggerinterface log = loggerfactory .getlogger(mybeackingbean.class);

the xml format of log4j should follow pattern

<!element log4j:configuration (renderer*, appender*,(category|logger)*,root?, categoryfactory?)>

all appenders should declared before loggers

so log4j.xml should next

<?xml version="1.0" encoding="utf-8" ?> <!doctype log4j:configuration scheme "log4j.dtd"> <log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="abclog4j" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/myapp/app/myserver/myproj/domains/logs/abclog.log"/> <param name="append" value="true"/> <param name="maxfilesize" value="5000kb"/> <param name="maxbackupindex" value="5"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> <appender name="stdout" class="org.apache.log4j.consoleappender"> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> <appender name="xyzlog4j" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/myapp/app/myserver/myproj/domains/logs/xyzlog.log"/> <param name="append" value="true"/> <param name="maxfilesize" value="5000kb"/> <param name="maxbackupindex" value="5"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> </layout> </appender> <logger name="com.mywhole.mysub.xyz" additivity="false"> <level value="info"/> <appender-ref ref="xyzlog4j"/> </logger> <logger name="com.mywhole.mysub.abc" additivity="false"> <level value="info"/> <appender-ref ref="abclog4j"/> </logger> ....................... <root> <priority value="error"/> <appender-ref ref="sysoutlog4j"/> </root>

check link more details here

jsf java-ee logging log4j

No comments:

Post a Comment