I also encouterned the log4j configuration in JBoss 7.1.1.Final, no doubt I had read the related reference doc and forum posts. but i can not find the solution for my project,
1. I want to use log4j and slf4j together in my project, and I want to use standalone log4j configuration for my project. so I do not want to config it in the JBoss AS.
2. I excluded log4j in the jboss deplyment file in my project as described in the user gudie.
2. my config file conftent is :
#### Use two appenders, one to log to console, another to log to a file log4j.rootCategory=INFO, stdout, R #### First appender writes to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F%L) - %m%n #### Second appender writes to a file log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=tickler-project.log # Control the maximum log file size log4j.appender.R.MaxFileSize=10000KB # Archive log files (one backup file here) log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n log4j.logger.com.company=DEBUG log4j.logger.org.apache.velocity=INFO
The result is it alwasy using "INFO" level in my project.
My purpose is using "DEBUG" in my classes, and otthers are using "INFO"....
I used the similar configurations in serveral projects, run on tomcat or JBoss 7.0.x, it worked well.
Is this is a bug or I omitted something some where?
Can you paste an example of the log? My guess would be your seeing the stdout wrapped in an INFO messages. My guess is you're seeing something like the following.
08:21:01,648 INFO [stdout] (http-localhost-127.0.0.1-8080-1) log4j:DEBUG Some message
If that's the case there is not a lot you can do. You could define a logger with a category stdout and give it a format of "%s%n". It seems it should work, though I admit I didn't test it.
James R. Perkins
In that case it doesn't look like your log4j configuration is being picked up. Is this a WAR or EAR? Where is the log4j configuration file located?
Also make sure you included a log4j library in your deployment. There is some information on the documentation too.
James R. Perkins
it worked...but only print the INFO level info...I included two INFO message in my project, one for ApplciationInitializer and one for logged in, I saw the two messages when it was deployed into JBoss AS.
I have read the JBoss AS docuement, excluded the log4j dependencies in the deployment file, and added my log4j in my proejct.
My project is WAR packing. log4j.properties is in the classpath(src/main/resources), jboss-deployment-structure is in WEB-INF.
the same result...
The jbosss deployment strcuture, either I put it into /META-INF or /WEB-INF or /WEB-INF/classes/META-INF, I got the same result.
<jboss-deployment-structure> <deployment> <!-- <dependencies> <module name="org.jboss.logmanager" /> </dependencies> --> <exclusions> <module name="org.apache.log4j" /> </exclusions> </deployment> </jboss-deployment-structure>
the log4.properties file, I think I must put into into the class path...I put it into /src/main/resouces, finally deployed into /WEB-INF/classes. if put it into the /WEB-INF/lib, I will got an error from Prettyfaces. I do not understand what is the "lib" in the JBoss documentation.
Log4j dependencies delcaration in pom.xml.
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.2</version> <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>runtime</scope> </dependency>
OK...I am not sure if this can be considered as a bug ...I have just updated my seam3-sandbox project on github, added deployment for jboss 7.1.1.Final.
I have just tried in JBoss 7.0.2.Final and JBoss 7.1.1.Final.
For jboss 7.0.2.Final:
mvn clean packaget jboss-as:deploy -Pjboss7
For JBoss 7.1.1.Final:
mvn clean package jboss-as:deploy -Pjboss71
If this is a bug, I will a new issue on JBoss JIRA.
BTW, the sandbox is a sample project where I was trying to use JBoss seam3 projects...do not care about the code quaulity here, care the logging only.
Hi, sorry I ran into the same problem, try following the steps but still I can not fix it
I create a file jboss-deployment-structure.xml in the / META-INF but still do not show the debug, the info if the log shows
I think my project has the same structure and I think my problem would be solved in the same way, but maybe I'm missing some step
They could tell me what to do step by step to solve this problem, I'm new in this
Thanks in advance
Are you using JBoss AS 7.1.1.Final as well? Excluding the logging dependencies should be all you need to do with JBoss AS 7.1.x.Final. If you have other logging dependencies, like commons-logging, you might need to exclude those as well.
Also if it's an EAR you would need to exclude the logging dependencies for each subdeployment as well.
James R. Perkins