You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Dignesh <dg...@opentext.com> on 2016/06/03 11:40:40 UTC

Need help on setting up log4j.xml

Hello,
I have created custom log4j.xml file and placed in the conf directory.I dont
see any file with logging getting generated. I have placed log4j.jar in the
lib folder as well

Can any one please help me where I am going wrong.Is there any other
configuration setting where i am missing ? 

Attached is the log4j.xml which I have placed in the conf folder.


log4j.xml
<http://tomee-openejb.979440.n4.nabble.com/file/n4678735/log4j.xml>  



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
it just loads it as a log4j.properties file so using log4j properties
syntax it works.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-06 15:46 GMT+02:00 Dignesh <dg...@opentext.com>:

> so you mean I can use the logging.properties for log4j configuration. -I
> assume that we need to add log4j.xml content in to logging.properties to
> achieve this ?
>
> Or
>
> Can you please provide me example of logging.properties which uses
> log4j.xml.
>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678778.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
so you mean I can use the logging.properties for log4j configuration. -I
assume that we need to add log4j.xml content in to logging.properties to
achieve this ?

Or 

Can you please provide me example of logging.properties which uses
log4j.xml.






--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678778.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-06-06 10:35 GMT+02:00 Dignesh <dg...@opentext.com>:

> Thank you very much..It is working now.
>
> Is there any way we can eliminate adding the log4j.jar and log4j.xml in
> tomee lib directory and generate logging.Because the way now it is working
> is, we need them to be added in tomee lib directory.
> Is there any other way we can do by modifying the logging.properties file
> present in conf folder.
>
>
Should be the default (ie external property set to false)


> The reason why I need this is we dont want any log4j.jar,log4j.xml files
> that needs to be added in TomEE lib directory.
>
>
Strictly speaking it needs to be in the classloader of the logger. If you
want tomee to use log4j you need to put it in tomee classloader ie
common.loader of tomcat (you can create other folders if you prefer). If
that's just for the app but not tomee then putting them all in the webapp
works.


> Please advise further.
>
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678768.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
Thank you very much..It is working now.

Is there any way we can eliminate adding the log4j.jar and log4j.xml in
tomee lib directory and generate logging.Because the way now it is working
is, we need them to be added in tomee lib directory.
Is there any other way we can do by modifying the logging.properties file
present in conf folder.

The reason why I need this is we dont want any log4j.jar,log4j.xml files
that needs to be added in TomEE lib directory.

Please advise further.


Thanks




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678768.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
1. system.properties:

openejb.log.factory = log4j
openejb.logger.external = true
log4j.debug=true

2.lib/log4j.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >

<log4j:configuration debug="false" xmlns:log4j="
http://jakarta.apache.org/log4j/" >

        <appender name="console" class="org.apache.log4j.ConsoleAppender">
                <param name="Target" value="System.out"/>
                <param name="Threshold" value="INFO"/>

                <layout class="org.apache.log4j.PatternLayout">
                        <!-- The default pattern: Date Priority [Category]
Message\n -->
                        <param name="ConversionPattern" value="media ->
%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                </layout>
        </appender>
        <appender name="openejb" class="org.apache.log4j.ConsoleAppender">
                <param name="Target" value="System.out"/>
                <param name="Threshold" value="INFO"/>

                <layout class="org.apache.log4j.PatternLayout">
                        <!-- The default pattern: Date Priority [Category]
Message\n -->
                        <param name="ConversionPattern" value="openejb ->
%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                </layout>
        </appender>


        <appender name="file" class="org.apache.log4j.RollingFileAppender">
                <param name="ImmediateFlush" value="true" />
                <param name="MaxFileSize" value="100MB" />
                <param name="MaxBackupIndex" value="10" />
                <param name="File" value="logs/mediamanager.log" />
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern"
                        value="%t %d{ISO8601} | %-5p |
session=%-6X{SESSION_ID} | user=%-10X{USER_ID} | %c | %m%n"/>
                </layout>
        </appender>

        <logger name="OpenEJB">
                <level value="INFO"/>
                <appender-ref ref="openejb" />
        </logger>
        <logger name="dignesh">
                <level value="INFO"/>
                <appender-ref ref="console" />
                <appender-ref ref="file" />
        </logger>
</log4j:configuration>

conf/jars.txt (was too lazy to download log4j.jar):

mvn:log4j:log4j:1.2.17


Then I get openejb logs on log4j (openejb appender). I don't get apps logs
but not sure you expect it




Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-03 19:13 GMT+02:00 Dignesh <dg...@opentext.com>:

> artesia.ear
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678751/artesia.ear>
> system.properties
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678751/system.properties
> >
> log4j.xml
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678751/log4j.xml>
> tomee.xml
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678751/tomee.xml>
>
> Attached ear ,conf/system.properties,conf/log4j.xml,tomee.xml
> Version of tomee plus  1.7 M3
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678751.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
artesia.ear
<http://tomee-openejb.979440.n4.nabble.com/file/n4678751/artesia.ear>  
system.properties
<http://tomee-openejb.979440.n4.nabble.com/file/n4678751/system.properties>  
log4j.xml
<http://tomee-openejb.979440.n4.nabble.com/file/n4678751/log4j.xml>  
tomee.xml
<http://tomee-openejb.979440.n4.nabble.com/file/n4678751/tomee.xml>  

Attached ear ,conf/system.properties,conf/log4j.xml,tomee.xml
Version of tomee plus  1.7 M3



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678751.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Maybe try to take the time to setup your installation with
tomee-maven-plugin to reproduce it and share us something we can inspect
(src/main/tomee/conf for conf folder, src/main/tomee/libfor lib folder and
<libs><lib>log4j:log4j:1.2.17</lib></libs> to add log4j to libs. Finally
mvn tomee:run to start)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-03 19:02 GMT+02:00 Dignesh <dg...@opentext.com>:

> Still the same issue
>
> Attached system.properties file system.properties
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678749/system.properties
> >
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678749.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
Still the same issue 

Attached system.properties file system.properties
<http://tomee-openejb.979440.n4.nabble.com/file/n4678749/system.properties>  



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678749.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Add in conf/system.properties:

openejb.logger.external=true

Otherwise we historically read some particular files not very intuitively.
Le 3 juin 2016 19:30, "Dignesh" <dg...@opentext.com> a écrit :

> Hi,
>
> Below are my configurations
>
> 1.added log4j.xml in conf folder
> 2.Added openejb.log.factory = log4j property in system.property file
> 3.Added commons-logging and log4j.jars in lib directory
>
> I am seeing the below warn messages in log. Is there any other
> configuration
> which i am missing .If not how can i turn on the log4j.debug to drill down
> the issue further.
>
>
> log4j:WARN No appenders could be found for logger
> (dignesh.tomee.learning.TestCl
> ass1).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more in
> fo.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678747.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
Hi,

Below are my configurations

1.added log4j.xml in conf folder
2.Added openejb.log.factory = log4j property in system.property file
3.Added commons-logging and log4j.jars in lib directory

I am seeing the below warn messages in log. Is there any other configuration
which i am missing .If not how can i turn on the log4j.debug to drill down
the issue further.


log4j:WARN No appenders could be found for logger
(dignesh.tomee.learning.TestCl
ass1).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more in
fo.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678747.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-06-03 14:05 GMT+02:00 Dignesh <dg...@opentext.com>:

> I have placed the xml in the same classloader of log4j.jar (lib directory),
> still i dont see any log getting generated.
>
> What is the system property that needs to added to point the log4j location
> ?
>
>
>
-Dlog4j.configuration=...

you can also activate log4j.debug to know what happen

Note that if you want to use it with tomee you will likely need
-Dopenejb.log.factory=log4j.


>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678737.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Need help on setting up log4j.xml

Posted by Dignesh <dg...@opentext.com>.
I have placed the xml in the same classloader of log4j.jar (lib directory),
still i dont see any log getting generated.

What is the system property that needs to added to point the log4j location
?



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735p4678737.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Need help on setting up log4j.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Either set the system property to init the location of log4j or put the xml
in lib dir too (in the same classloader as log4j)
Le 3 juin 2016 14:18, "Dignesh" <dg...@opentext.com> a écrit :

> Hello,
> I have created custom log4j.xml file and placed in the conf directory.I
> dont
> see any file with logging getting generated. I have placed log4j.jar in the
> lib folder as well
>
> Can any one please help me where I am going wrong.Is there any other
> configuration setting where i am missing ?
>
> Attached is the log4j.xml which I have placed in the conf folder.
>
>
> log4j.xml
> <http://tomee-openejb.979440.n4.nabble.com/file/n4678735/log4j.xml>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Need-help-on-setting-up-log4j-xml-tp4678735.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>