-
1. Re: JBOSS logging
sfcoy Nov 5, 2012 9:32 PM (in response to michadmin)Hi there,
Welcome to JBoss!
Depending upon what you mean by "Application code independent of any actual implementation", you may not need to do anything at all.
You can control what gets logged from the admin console or use the CLI.
-
2. Re: JBOSS logging
michadmin Nov 5, 2012 11:22 PM (in response to sfcoy)How do i enable standard Java Logging on jboss ? For example, if there is an issue in app and we need to enable trace for troubleshooting.
In WebSphere this option is already implemented in console where you can enable diagnostic trace on the fly. Is there something similar in jboss?
Do you know of any articles on jboss logging and examples other than the documentation?
Thank you,
AdminMich
-
3. Re: JBOSS logging
sfcoy Nov 6, 2012 12:09 AM (in response to michadmin)Have you seen AS71 Logging Configuration?
-
4. Re: JBOSS logging
michadmin Nov 6, 2012 1:45 PM (in response to sfcoy)Thanks for your reply, Yes i have checked it out but i am confused on how to enable logging for a specific class for an application. I see that there is a custom handler but i am not sure how to configure it. Is there any info about that?
I need to be able to enable logs for specific app classes (for example com.classname*=all=enabled)
-
-
6. Re: JBOSS logging
sfcoy Nov 6, 2012 6:30 PM (in response to michadmin)You can also use the CLI interface to do the same thing:
{code:bash}bin/jboss-cli.sh --connect "/subsystem=logging/logger=com.classname:add(level=DEBUG)"{code}
-
7. Re: JBOSS logging
michadmin Nov 8, 2012 10:14 AM (in response to sfcoy)Thanks, does this require a restart? Can it be applied in runtime? Also if you have multiple classes you have to add each and every class manually?
Cheers,
AdminMich
-
8. Re: JBOSS logging
jamezp Nov 8, 2012 4:03 PM (in response to michadmin)It can be applied at runtime. Nearly all the logging configuration changes do not require a restart.
--
James R. Perkins
-
9. Re: JBOSS logging
sfcoy Nov 8, 2012 5:34 PM (in response to michadmin)Michel G wrote:
... Also if you have multiple classes you have to add each and every class manually?
Normally, just the package name is used. This encompasses all classes in the package as well as subpackages:
{code:bash}bin/jboss-cli.sh --connect "/subsystem=logging/logger=com.package.name:add(level=DEBUG)"{code}
-
10. Re: JBOSS logging
michadmin Nov 14, 2012 3:26 PM (in response to sfcoy)Thanks i see the app logging under server.log, i want to have a separate file for the application logs. i have configured a new Size Rotating File Handler (along with pointing the class to use it) and i can see the new app.log file but it is empty and the logging is still going to server.log.
Any ideas?
Cheers
-
11. Re: JBOSS logging
jamezp Nov 14, 2012 4:51 PM (in response to michadmin)You need to create a logger (category) and assign the handler to it.
<subsystem xmlns="urn:jboss:domain:logging:1.0"> ... <size-rotating-file-handler name="myapp-handler" auto-flush="true"> <level name="INFO"/> <formatter> <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> </formatter> <append value="true"/> <file relative-to="jboss.server.log.dir" path="myapp.log"/> <max-backup-index value="10"/> <rotate-size value="100m"/> </size-rotating-file-handler> <logger category="com.myapp" use-parent-handler="false"> <handlers> <handler name="myapp-handler"/> </handlers> </logger> ... </subsystem>
If you want your messages to also go to the server.log just remove the use-parent-handler attribute or set it to true.
--
James R. Perkins
-
12. Re: JBOSS logging
michadmin Nov 14, 2012 5:44 PM (in response to jamezp)Yes my configuration is alomst the same, i have defined the logger and i even restarted all jboss instance but it still doesnt print in app.log. When i changed use-parent-handler='false' from true it stopped printing in server.log but app.log is still empty. Am i missing something in configuration below?
<subsystem xmlns="urn:jboss:domain:logging:1.0">
Logssizebased
...
<size-rotating-file-handler name="" auto-flush="false">
org.apache.jsp.test
<level name="INFO"/>
<file relative-to="jboss.server.log.dir" path="app.log"/>
</size-rotating-file-handler>
<logger category="" use-parent-handler="false">
<level name="WARNING"/>
<handlers>
Logssizebased
<handler name=""/>
</handlers>
</logger>
...
</subsystem>PS: i have configured it thru management console, not sure if it makes a difference
-
13. Re: JBOSS logging
jamezp Nov 14, 2012 5:54 PM (in response to michadmin)1 of 1 people found this helpfulI would set the auto-flush to true, but other than that it looks okay. Are all the loggers in your application using something like Logger.getLogger("org.apache.jsp.test")? Also are you printing error and warning messages? The way you have the logger setup is it will only print WARNING or higher messages.
Nope, I would suggest configuring through the management console instead of updating the XML by hand
--
James R. Perkins
-
14. Re: JBOSS logging
michadmin Nov 14, 2012 6:15 PM (in response to jamezp)Thanks it works when i set auto-flush to true.
For some reason auto-flush must be set to true or else it will not work. Does this happen in your environment too?