-
1. Re: Customizing logging format in Jboss 7 AS
prasad.deshpande Aug 23, 2011 5:05 AM (in response to dkumaran)Formatting is same as log4j-style as defined in documentation of PatternLayout class of log4j, except that jboss pattern doesn't not accept "M" & "L" conversion characters.
see API docs for org.jboss.logmanager.formatters.FormatStringParser class & http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html for patterns.
-
2. Re: Customizing logging format in Jboss 7 AS
dkumaran Aug 24, 2011 1:40 AM (in response to prasad.deshpande)i just want to reframe my question here like this..
i have a class "CustomLayout" which extended from PatternLayout and i want to use the same here in JBoss 7AS Is that possible
In a log4j.xml we can give the same as below
<appender name="R" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="d:/server/log/samplelog4j.log" />
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="10" />
<layout class="com.learning.log4j.CustomLayout">
<param name="ConversionPattern" value="[%r,%c{1},%t] %m%n"/>
</layout>
</appender>
So in Jboss 7 AS can i specify in standalone.xml
<subsystem xmlns="urn:jboss:domain:logging:1.0">
<console-handler name="CONSOLE" autoflush="true">
<level name="INFO"/>
<formatter>
<pattern-formatter class="com.learning.log4j.CustomLayout" pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</console-handler>
-
3. Re: Customizing logging format in Jboss 7 AS
jaikiran Aug 24, 2011 1:51 AM (in response to dkumaran)You don't have to configure logging in the standalone.xml. If you are using log4j, then just package the log4j.xml and the log4j and your custom layout class to get it working.
-
4. Re: Customizing logging format in Jboss 7 AS
dkumaran Aug 24, 2011 2:59 AM (in response to jaikiran)Jai,,
have you tried the same in JBoss 7 AS, i have tried a sample application with log4j.xml. but i couldn't see the app.log file, the source of the sample application is attached in the discussion thread..
http://community.jboss.org/thread/171287?tstart=0
if you have some working samples can you share with us. ?
-
5. Re: Customizing logging format in Jboss 7 AS
jaikiran Aug 24, 2011 3:22 AM (in response to dkumaran)kumaran d wrote:
Jai,,
have you tried the same in JBoss 7 AS, i have tried a sample application with log4j.xml.
I haven't. But one other user has http://community.jboss.org/message/621302#621302
-
6. Re: Customizing logging format in Jboss 7 AS
prasad.deshpande Aug 24, 2011 4:43 AM (in response to dkumaran)All you have to do is to make available your log4j.xml in application classpath. Make sure that your log4j.xml is found by application, most of the time that is the problem. If you are not sure, then just bundle it in jar file & drop that jar in your lib directory (If your application is packaged as EAR then ear/lib, if it's WAR, then in WEB-INF/lib or just drop log4j.xml in WEB-INF/classes directory).
I'll take a look at your attached sample application (http://community.jboss.org/thread/171287?tstart=0) to see what's going on.
-
7. Re: Customizing logging format in Jboss 7 AS
prasad.deshpande Aug 24, 2011 7:33 AM (in response to prasad.deshpande)1 of 1 people found this helpfultake a look at http://community.jboss.org/message/622668#622668
-
8. Re: Customizing logging format in Jboss 7 AS
dkumaran Sep 6, 2011 5:51 AM (in response to prasad.deshpande)i could able to add the customized Layout and it's working with your reference.
Thanks a lot.
-
9. Re: Customizing logging format in Jboss 7 AS
mpgong Jan 24, 2012 12:42 PM (in response to dkumaran)Didn't want to start a new thread since my question is related.
But if M and L can't be used how can i get the method and line number? Is that possible or would i need to switch and use log4j?
Also, in the pattern corrently defaulted pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n" what does the E mean.
Is there documentation on this? I checked the one for log4j patternlayout and there a some difference. like s here is the message which was mentioned in the JBoss 7 config admin book.
Thanks
-
10. Re: Customizing logging format in Jboss 7 AS
jamezp Jan 26, 2012 5:26 PM (in response to mpgong)1 of 1 people found this helpfulMichael,
Both %M and %L should work in a pattern should work. There is no reason to use log4j, the JBoss Log Manager will recognize the format. This pattern "%d{HH:mm:ss,SSS} %-5p [%c.%M:%L] (%t) %s%E%n" works for me.
14:19:06,931 INFO [test.testConfig:71] (main) Test message should show up on the console.
The %E in the default pattern is for a Throwable. Meaning it will print the stacktrace if an exception is being logged.
--
James R. Perkins
-
11. Re: Customizing logging format in Jboss 7 AS
herb Jul 23, 2012 6:05 AM (in response to prasad.deshpande)Formatting is same as log4j-style as defined in documentation of PatternLayout class of log4j
No, JBoss logger has different output compared to log4j PatternLayout:
Try [%20c] [%-20c] [%.20c] [%10.20c] [%-10.20c] with log4j and JBoss logger and you see completely different output (JBoss logger does not support all log4j patterns/formatting rules)
-
12. Re: Customizing logging format in Jboss 7 AS
jamezp Jul 23, 2012 12:27 PM (in response to herb)For the most part JBoss Log Manager's pattern formatter should parse most log4j style formats. If there are some specific formats you would like to be parsed, feel free to file a detailed JIRA of the specific deficiency.
--
James R. Perkins
-
13. Re: Customizing logging format in Jboss 7 AS
smmehadi Sep 7, 2012 6:26 AM (in response to jamezp)Can i provide the timezone in the customized formatter ( %d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n )?
and/or if i want to change the time (to be output to log file), to some other timezone (to match other servers time), how can i do that.
-
14. Re: Customizing logging format in Jboss 7 AS
jamezp Sep 7, 2012 1:24 PM (in response to smmehadi)It just uses the java.text.SimpleDateFormat so yes. Just use z or Z options.
Example:
%d{HH:mm:ss,SSS Z} %-5p [%c] (%t) %s%E%n
--
James R. Perkins