-
1. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
jaikiran Oct 29, 2005 9:41 AM (in response to newgro)You can use log4j for logging from the EJBs. There's one log4j.xml in server/default/conf where you can specify the settings for log4j. However, if you want a specific log4j.xml for your application, you can also do that.
Please, have a look at:
http://wiki.jboss.org/wiki/Wiki.jsp?page=Logging -
2. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
newgro Oct 31, 2005 5:08 AM (in response to newgro)Thanks jaikiran for the reply. I haven't read the wiki. Sorry for that.
I decided to use the "Redirecting Category Output" task to solve my problem.
Added an appender and the top level package category to log4j.xml.
The problem is that the log-file is empty.
Here is what i added:<appender name="ApplLog" class="org.apache.log4j.FileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/> <param name="Append" value="false"/> <param name="File" value="${jboss.server.home.dir}/log/my-appl.log"/> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/> <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> --> </layout> </appender> ... <!-- Limit the top level application package --> <category name="de.myfirm" additivity="false"> <priority value="INFO"/> <appender-ref ref="ApplLog"/> </category>
Looked at many examples but haven't found any solution. Is it possible that this is only working if the EJBs are logging by usage of log4j?
Thx
Per -
3. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
jaikiran Oct 31, 2005 12:29 PM (in response to newgro)Let me explain, the way log4j looging works in jboss. During jboss startup there is a LoggingService that is started. This service reads a log4j.xml file present in server/default/conf directory and creates appropriate appenders. (Thats the reason why your my-appl.log file is created). Then whenever a logging statement is issued from some class, using a logger, through log4j's API then the appropriate appenders are used to log the message. To see the log messages in the my-appl.log file, you will have to log4j APIs in your EJBs. Try it out, its simple.
-
4. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
jaikiran Oct 31, 2005 12:34 PM (in response to newgro)This link will get you started with log4j, if you are not familiar with it:
http://www.developer.com/open/article.php/3097221 -
5. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
newgro Nov 1, 2005 2:32 AM (in response to newgro)Ok, thanks.
That means that the answer to my second questionIs it possible to achieve this without code-changes in EJBs or exchanging JDK-API by Log4J-API (I don't want to use AOP or something like that)?
is NO. -
6. Re: Combine Log4J of JBoss and JDK-Log of own EJBs
jaikiran Nov 5, 2005 7:25 AM (in response to newgro)Please have a look at:
JDK java.util.logging section at:
http://wiki.jboss.org/wiki/Wiki.jsp?page=Logging
I guess, this is exactly what you are looking for. You need NOT have to change your existing code. However, i think you will have to introduce a new class, which is described in that section.