-
1. Re: jboss-eap-6.1 + log4j configuration
jamezp Aug 13, 2013 11:56 AM (in response to bubusettete)To use log4j loggers you don't need to do anything to make it work. If you want to configure the log4j log manager for your application you have two options. The first and easiest option is just to include a log4j.xml or log4j.properties file in your applications META-INF or WEB-INF/classes path.
The second option is to add a jboss-deployment-structure.xml file and exclude the servers log4j module, https://docs.jboss.org/author/display/AS72/How+To#HowTo-HowdoIuselog4j.propertiesorlog4j.xmlinsteadofusingtheloggingsubsystemconfiguration%3F.
There is no way to configure the system/server level logging with log4j.
--
James R. Perkins
-
2. Re: jboss-eap-6.1 + log4j configuration
bubusettete Aug 13, 2013 12:07 PM (in response to jamezp)thank you James for your quick response!
Ok, I'll try with the first option ..
Another question, is there a way to tell the server to create the log file in a directory of your choice (example: C:\MyApp\log)-Thanks
-
3. Re: jboss-eap-6.1 + log4j configuration
jamezp Aug 13, 2013 12:20 PM (in response to bubusettete)1 of 1 people found this helpfulYes. You can either hard-code that in the file attribute on the handler, e.g. remove the relative-to attribute and specify the full path or pass the system property jboss.server.log.dir=C:\MyApp\log.
One catch with the system property is that during the bootstrap logging the logging.properties file is used. So on the initial boot when you change the system property if you don't change the logging.properties file paths then until the logging subsystem kicks in the logs will be sent to the old location. The logging.properties file will be rewritten during the subsystem initialization though. Which means on subsequent boots the logs will go to the new path.
--
James R. Perkins
-
4. Re: jboss-eap-6.1 + log4j configuration
bubusettete Aug 13, 2013 12:32 PM (in response to jamezp)You mean to modify this entry : <file relative-to="jboss.server.log.dir" path="server.log"/> of the standalone.xml file
under the directory D:\jboss-eap-6.1\standalone\configuration ?
-
5. Re: jboss-eap-6.1 + log4j configuration
jamezp Aug 13, 2013 12:45 PM (in response to bubusettete)1 of 1 people found this helpfulYou can do that, but I would use CLI or the web admin console rather than updating the XML manually. The same one-off print to the old directory will happen if you change the XML and don't change the logging.properties file as well.
The advantage to changing the system property is now any handler that uses the relative-to attribute for the file will go to your directory.
--
James R. Perkins
-
6. Re: jboss-eap-6.1 + log4j configuration
bubusettete Aug 13, 2013 12:53 PM (in response to jamezp)I understand, thanks James for the quick responses and your courtesy.
Alessandro
-
7. Re: jboss-eap-6.1 + log4j configuration
sarada.ch Mar 30, 2017 11:10 PM (in response to jamezp)Hi James,
Mine in Standalone.jar file. I have copied my log4j.properties file in META-INF.
# Root logger option
log4j.rootLogger=INFO, stdout, file
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.Threshold=WARN
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Direct log messages to a daily esb.log.yyyy-MM-dd file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:/software/RedhatSSO/rh-sso-7.1/provider.log
log4j.appender.file.MaxFileSize=50MB
log4j.appender.file.MaxBackupIndex=50
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%nI can see my log file created but I feel more like duplicate because server.log and provider.log contains same logs.
I want warnings and error to server.log and everything else to application log.
Could you please help?
-
8. Re: jboss-eap-6.1 + log4j configuration
rohanemmanuel Mar 31, 2017 6:11 AM (in response to sarada.ch)you would need to change the log level for the periodic-rotating-file handle in domain.xml to error level, something like :
<level name="SEVERE"/>
Hope this helps.
-
9. Re: jboss-eap-6.1 + log4j configuration
jamezp Mar 31, 2017 11:20 AM (in response to sarada.ch)What version of JBoss EAP are you using? Some early versions of JBoss EAP 6 did have some issues with log4j configurations working correctly.
--
James R. Perkins
-
10. Re: jboss-eap-6.1 + log4j configuration
sarada.ch Apr 2, 2017 7:37 PM (in response to jamezp)I am not sure which version of JBoss EAP is used. As per the RedHat SSO 7.1 they had mentioned it supports JBoss EAP 7
-
11. Re: jboss-eap-6.1 + log4j configuration
jamezp Apr 3, 2017 1:37 PM (in response to sarada.ch)If it's EAP 7 then the log4j.properties you're using should just work for you. Assuming of course you use log4j for logging as well.
--
James R. Perkins