-
1. Re: Log4j properties file not working
apodgorsek Apr 3, 2012 2:48 AM (in response to apodgorsek)Anyone please?
-
2. Re: Log4j properties file not working
ctomc Apr 3, 2012 5:06 AM (in response to apodgorsek)Hi,
so what do you have? log4j.jar in your app or is log4j imported via dependancy? you have posted both... that might give you problems...
--
tomaz
-
3. Re: Log4j properties file not working
sfcoy Apr 3, 2012 6:28 AM (in response to apodgorsek)A few questions:
- Is this a WAR file only deployment, with your log4j.jar in the WEB-INF/lib directory?
- What mechanism are you using to tell log4j where your "external" properties file is located?
- Have you verified that there are no other copies of log4j.properties lying around in the classpath, such as in the WEB-INF/classes directory?
-
4. Re: Log4j properties file not working
apodgorsek Apr 3, 2012 7:05 AM (in response to ctomc)I would prefer using the default one, which comes with jboss if possible...i really dont care about versions. But as I have emphasized, it takes log4j.properties from the location and creates the log file specified in it, it just doesnt print in it anything...only in server log. And If i go in the debug mode in log4j. properties it also maked debug messages about jboss internals in console, so the server log gets to 50+mb easily.
A sample maven war or ear with a servlet which logs into file that is specified in a log4j.properties destination, would be appriciated.
-
5. Re: Log4j properties file not working
ctomc Apr 4, 2012 8:25 AM (in response to apodgorsek)Hi,
why don't you manage logging configuration centraly aka in loggin subsystem?
You can configure all you want to achive you will have centralized configuration which is easier to mentain.
Just remove log4j.properties and import log4j/slf4j via dependancies and make sure you dont ship your own log4j/slf4j and it will work as charm
--
tomaz
-
6. Re: Log4j properties file not working
apodgorsek Apr 4, 2012 9:24 AM (in response to ctomc)Any sample archetype/war?
-
7. Re: Log4j properties file not working
ctomc Apr 4, 2012 9:30 AM (in response to apodgorsek)no example needed, all you need is to remove log4j/slf4j/whatever jar from your war.
and import it via dependancies
for instance:
<manifestEntries>
<Dependencies>org.apache.log4j</Dependencies>
<manifestEntries>
and that is it. configuration is then done in standalone.xml (or whatever you use) or console, where you can define new logger(aka category in log4j) and new appenders.
that is it.
for more about how to configure logging: https://docs.jboss.org/author/display/AS71/Logging+Configuration
--
tomaz
-
8. Re: Log4j properties file not working
thinksteep Apr 4, 2012 3:38 PM (in response to ctomc)Hi All,
I am having similar issue. My case is little bit complex and we are using log4j.xml. I copied log4j.jar in my EAR/lib and app-log4j.xml. It seems initiation and things are going fine, but log file is with size ZERO. Everything logged to server.log.
We have initiation class where we are loading app-log4j.xml to create logger. I have created another for my issue. Could some one help me?
https://community.jboss.org/thread/197945
Thanks for your time and help.
-
9. Re: Log4j properties file not working
thinksteep Apr 4, 2012 6:13 PM (in response to thinksteep)Never mind. I fixed it. It was issue with log4j module exclusion from jboss-deployment-structure.xml.
-
10. Re: Log4j properties file not working
apodgorsek Apr 16, 2012 12:07 PM (in response to apodgorsek)I've attached a sample of webapp which just prints out empty .log file...everything after that is just put to console appender (instead of file which is on path C:\\log\\... with log4j properties also).
Can you also elaborate about jboss-deployment what was the solution configuration for you?
I must stress out it is crucial for me, for configuration to be done via external .properties file which is on filesystem.
-
log4jtest.rar.zip 89.3 KB
-
-
11. Re: Log4j properties file not working
jamezp Apr 16, 2012 1:04 PM (in response to apodgorsek)Andrej,
Have a look at the logging documentation, https://docs.jboss.org/author/display/AS71/How+To#HowTo-HowdoIuselog4j.propertiesorlog4j.xmlinsteadofusingtheloggingsubsystemconfiguration%3F. That should do the trick to exclude the servers log4j library. Note though that using a log4j.properties file does not allow you to change your logging configuration for your application at runtime like using the logging subsystem would.
-
12. Re: Log4j properties file not working
apodgorsek Apr 16, 2012 5:30 PM (in response to jamezp)As I can get it work in a simple, one module web application, it seems not to work in a multi module (web,ear,...) project.
Here is an example, where I also get just an empty .log file. Properties file is from a sample above.
-
Test.rar.zip 78.1 KB
-
-
13. Re: Log4j properties file not working
apodgorsek Apr 17, 2012 5:39 AM (in response to apodgorsek)It is rather interesting that it doesn't work in multi module project.
Any help would be appriciated!
-
14. Re: Log4j properties file not working
sfcoy Apr 17, 2012 8:14 AM (in response to apodgorsek)You need to make a couple of changes to fix your example:
- Remove the redundant log4j.jar file by updating to version 2.7 of the maven-ear-plugin and configure it to build skinny wars. This removes jars from the WEB-INF/lib directory that are also in the EAR/lib directory.
{code:xml}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
<modules>
<webModule>
<groupId>Grp</groupId>
<artifactId>Test-web</artifactId>
<contextRoot>/Test</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
{code}
- Move the jboss-deployment-structure.xml file from the EJB jar to the META-INF directory of the EAR file. The maven-ear-plugin expects to find it in /src/main/application/META-INF. Note that the documentation kindly provided by James Perkins mentions placing this file only in EAR files and WAR files.
- Remove the redundant log4j.jar file by updating to version 2.7 of the maven-ear-plugin and configure it to build skinny wars. This removes jars from the WEB-INF/lib directory that are also in the EAR/lib directory.