Hi

I tried having different appender for application and framework in this way.

Framework log properties

log4j.rootLogger=INFO, stdout,R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n

log4j.logger.org.apache.zookeeper=ERROR
log4j.logger.org.I0Itec.zkclient=ERROR


Application log properties which are part of the executable jar and its like

log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File = logs/sample.log
log4j.appender.R.Append = true
log4j.appender.R.DatePattern = '.'yyy-MM-dd
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1}
[%p] %m%n

But what happens here is , the application log4j proeprties are overridden
by the framework properties and the second one has no effect at all.

Thank You,
Sreejith


On Thu, Apr 20, 2017 at 11:17 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> Sreejith,
>
> On 4/20/17 10:53 AM, Sreejith S wrote:
> > I will try this Chandra.  Thank you
>
> Specifically, you will want to look at and experiment with the
> "additivity" setting for a logger.
>
> -chris
>
> > On 20-Apr-2017 8:18 pm, "Chandra" <chandra.tungathur...@rwth-aachen.de>
> > wrote:
> >
> >> Hi Sreejith,
> >>
> >> If I understand it correctly. you want to separate the logs from your
> >> application and framework right?
> >>
> >> this is a pretty standard use case of log4j(1/2). I assume you are using
> >> log4j1.X as you mention `log4j.properties` ( keep in mind, this is
> >> deprecated/too old try moving to log4j2)
> >> you can define separate appenders for your application and framework
> >> loggers.
> >>
> >> some basic guide is here: https://www.tutorialspoint.com/log4j/
> >> log4j_configuration.htm
> >>
> >> thanks,
> >> Chandra
> >>
> >> On 20 Apr 2017, 7:05 PM +0530, Sreejith S <srssreej...@gmail.com>,
> wrote:
> >>> Hi All,
> >>>
> >>> I have an application running with in a framework. The framework has a
> >>> log4j.properties and assume its writing to a file. When i deploy my
> >>> application in framework the log file contains framework level logs
> plus
> >>> application logs.
> >>>
> >>> But i want to have application level logs only in the log output file.
> Or
> >>> segregate application level logs from framework logs and write it
> >>> separately.
> >>>
> >>> Is it possible ? If yes , what would be the approach ?
> >>>
> >>> Thanks & Regards,
> >>> --
> >>>
> >>>
> >>> *Sreejith.S*
> >>> https://github.com/srijiths/
> >>
> >
>
>
>
>


-- 


*Sreejith.S*
https://github.com/srijiths/
http://srijiths.wordpress.com/
tweet2sree@twitter <http://tweet2Sree>

Reply via email to