-
1. Re: Configuring log4j LoggerFactory using jboss-logging.xml
petal1 May 2, 2013 11:29 AM (in response to vijaycruise)Hi Vijay,
I know your post is an old one, but did you ever find an answer to your question?
Also, I am struggling to get the log4j appenders working in my JBoss 6.1.0.Final environment. I see that you have managed and I'm interested to know what you had to do. I too have applied the 8791 patch (even though it shouldn't have been necessary in 6.1.0). I have a simple. I have jboss-logging.xml with a simple appender configured like this, but I see nothing in serverx.log (in fact it is not even created):
<log4j-appender name="MYTEMPFILE" class="org.apache.log4j.RollingFileAppender">
<error-manager>
<only-once/>
</error-manager>
<level name="DEBUG"/>
<properties>
<property name="file">${jboss.server.home.dir}/log/serverx.log</property>
<property name="maximumFileSize">20480000</property>
<property name="maxBackupIndex">5</property>
</properties>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>
</formatter>
</log4j-appender>
<!-- tried this too
<logger category="com.myco">
<level name="DEBUG"/>
<handlers>
<handler-ref name="MYTEMPFILE"/>
</handlers>
</logger>
-->
...
<root-logger>
<!-- Set the root logger priority via a system property, with a default value. -->
<level name="${jboss.server.log.threshold:DEBUG}"/>
<handlers>
<handler-ref name="MYTEMPFILE"/>
<handler-ref name="CONSOLE"/>
<handler-ref name="FILE"/>
</handlers>
</root-logger>I've tried getting information from the forums, from the documentation (well, what there is of it !!).
Did you have to reference your appender in bin/logging.properties maybe?
Thanks,
Paul
-
2. Re: Configuring log4j LoggerFactory using jboss-logging.xml
vijaycruise May 6, 2013 4:42 AM (in response to petal1)Applying what I have to your example:
<?xml version="1.0" encoding="UTF-8"?>
<logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0">
<log4j-appender name="MYTEMPFILE" class="org.apache.log4j.RollingFileAppender">
<error-manager>
<only-once/>
</error-manager>
<level name="DEBUG"/>
<properties>
<property name="file">${jboss.server.home.dir}/log/serverx.log</property>
<property name="maxFileSize">20MB</property>
<property name="maxTotalSize">100MB</property>
</properties>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>
</formatter>
</log4j-appender>
<!-- tried this too
<logger category="com.myco">
<level name="DEBUG"/>
<handlers>
<handler-ref name="MYTEMPFILE"/>
</handlers>
</logger>
-->
...
<root-logger>
<!-- Set the root logger priority via a system property, with a default value. -->
<level name="${jboss.server.log.threshold:DEBUG}"/>
<handlers>
<handler-ref name="MYTEMPFILE"/>
<handler-ref name="CONSOLE"/>
<handler-ref name="FILE"/>
</handlers>
</root-logger></logging>
so basically,
1) I was not sure whether you had the <logging></logging> tags.
2) Couple of properties in the log4j appender has changed - maxFileSize and maxTotalSize. 20MB and 100MB means we will have a max of 5 files with 20MB each.
3) I don't have a level at the <root-logger>, I don't see that in the xsd I have linked in the original post either. It may not work.
try these, it should work.
Regards,
Vijay
-
3. Re: Configuring log4j LoggerFactory using jboss-logging.xml
petal1 May 9, 2013 5:37 AM (in response to vijaycruise)Hi Vijay,
Thank you for replying.
I didn't show the full jboss-logging.xml file in my post, and it turns out the problem I am seeing is caused by the inclusion of another log4j appender. If I remove that one, my file appender works ok.
The problem in the other appender is something to do with setting properties. I removed all my properties from the log4j-appender definition and added them back in 1 by 1. The first three worked fine, but as soon as I add my fourth property in, it breaks. The first three take a long as a parameter, the fourth takes an int. So it may be something to do with that, or it may be to do with the case of the property name - the setter method in my code is called setRMIPort so I have named the property rMIPort, i.e. I have lower-cased the first letter of the part after the 'set' - the same as I have done for the three properties that do work.
Anyway, it seems this is now not related to what you were experiencing.
Thank you,
Paul