Hi Scott, Thanks a lot ,
On Thu, Oct 31, 2013 at 10:25 AM, Scott Deboy <[email protected]> wrote: > Actually there is already a WebLookup, which supports 'contextPath', > 'servletContextName', etc. See: > http://logging.apache.org/log4j/2.x/manual/lookups.html > > On 10/30/13, Scott Deboy <[email protected]> wrote: > > What might be easiest is to use separate log4j configurations for each > > web app, specifying unique names in each web app's log4j configuration > > file. See http://logging.apache.org/log4j/2.x/manual/logsep.html for > > more information. > > > > http://logging.apache.org/log4j/2.x/manual/webapp.html mentions that > > the ServletContext's context name is used as the LoggerContext name, > > but the LoggerContext name isn't exposed anywhere that I can see as > > something you could use in the naming of your rolling file. > > > > You may be able to do this by implementing your own Lookup - see > > http://logging.apache.org/log4j/2.x/manual/extending.html > > > > Hope that helps. > > > > Scott > > > > On 10/30/13, Mahesh Dilhan <[email protected]> wrote: > >> Hi Scott > >> > >> thanks for the reply. > >> > >> Actually I wanted to know that how to get the > >> *web-application-context-path > >> dynamically, without hard-code in the log4j2.xml.* > >> * > >> * > >> *Sorry for the inconvenience, if i did not make my self clear .* > >> * > >> * > >> " is there a way to output log file name as : > >> "*web-application-context-path > >> *-date.log" ? [configuration of log4j2,xml]" > >> > >> Yes I did append the *"date"* by looking at RollingAppender. > >> > >> Thanks > >> > >> > >> > >> On Thu, Oct 31, 2013 at 6:48 AM, Scott Deboy <[email protected]> > >> wrote: > >> > >>> I'm not clear myself on when an async logger is useful - I am more > >>> familiar with the (previously existing) concept of async appenders. > >>> > >>> I think the documentation in this area needs to be enhanced to explain > >>> why you would use async loggers or async appenders, particularly for > >>> file IO. > >>> > >>> As for generating log files with dates, yes, you can specify your own > >>> date-related pattern with a RollingFileAppender. See the > >>> documentation on RollingFileAppender and examples here: > >>> http://logging.apache.org/log4j/2.x/manual/appenders.html > >>> > >>> Scott > >>> > >>> On 10/30/13, Mahesh Dilhan <[email protected]> wrote: > >>> > Hi Scott > >>> > > >>> > I already configured it , yes it works for fileAppeders. > >>> > I have seen the perftest of async logger. will there be performance > >>> > hit > >>> > with fileAppender compared to async logger? I already noticed time > >>> > taken > >>> > for initialization process is varying for file and random access > file. > >>> > is > >>> > it because of "distruptor"? > >>> > > >>> > is there a way to output log file name as : > >>> > "*web-application-context-path*-date.log" > >>> > ? [configuration of log4j2,xml] > >>> > > >>> > Thanks > >>> > > >>> > > >>> > > >>> > > >>> > On Thu, Oct 31, 2013 at 3:16 AM, Scott Deboy <[email protected]> > >>> wrote: > >>> > > >>> >> Mi Mahesh, > >>> >> > >>> >> If you'd like to use Chainsaw with log4j2, you need to use the > latest > >>> >> Chainsaw developer snapshot, available here: > >>> >> http://people.apache.org/~sdeboy > >>> >> > >>> >> If you use a file appender in your log4j configuration, add the > JmDns > >>> >> jar to your application classpath (http://jmdns.sourceforge.net), > and > >>> >> update your log4j configuration as described in the documentation > >>> >> (including specifying a URI to your log file), Chainsaw should be > >>> >> able > >>> >> to parse and tail your log file. > >>> >> > >>> >> Feel free to ask additional questions here on the user list. > >>> >> > >>> >> Scott > >>> >> > >>> >> On 10/28/13, Mahesh Dilhan <[email protected]> wrote: > >>> >> > Thanks for the clarification Remko > >>> >> > > >>> >> > > >>> >> > On Tue, Oct 29, 2013 at 8:52 AM, Remko Popma > >>> >> > <[email protected]> > >>> >> wrote: > >>> >> > > >>> >> >> Hi Mahesh, > >>> >> >> > >>> >> >> Thank you for re-posting your question to the user mailing list. > >>> >> >> > >>> >> >> The Status Logger is a special logger used by log4j internally. > >>> >> >> If you set it to "debug" or "trace" (by starting your config xml > >>> >> >> file > >>> >> >> with <Configuration > >>> >> >> status="debug">...), > >>> >> >> it will output things like which appenders and loggers were > >>> >> >> initialized, > >>> >> >> which log4j plugins were found, etc. > >>> >> >> Any configuration problems will show up in the status log. > >>> >> >> The status log output will appear on the console (System.out). > >>> >> >> > >>> >> >> In JConsole, this internal logging is what you see in the > >>> StatusLogger > >>> >> >> tab. > >>> >> >> > >>> >> >> I'm guessing from your question that you would like to see the > log > >>> >> >> statements produced by your application in the JConsole viewer. > >>> >> >> Unfortunately, JMX currently does not provide a way to show the > >>> >> >> content > >>> >> >> of > >>> >> >> application log files. > >>> >> >> > >>> >> >> If you are looking for a tool that allows you to view the log > file > >>> >> >> from > >>> >> a > >>> >> >> remote machine you may want to take a look at Chainsaw. > >>> >> >> http://logging.apache.org/chainsaw/ > >>> >> >> > >>> >> >> Scott Deboy has been doing work to make Chainsaw's zeroconf > >>> >> >> feature > >>> >> >> work > >>> >> >> well with log4j2. > >>> >> >> I am not that familiar with Chainsaw, but perhaps this > >>> >> >> documentation > >>> >> >> can > >>> >> >> get you started: > >>> >> >> > >>> >> >> > >>> >> > >>> > http://logging.apache.org/log4j/2.x/manual/configuration.html#AdvertisingAppenderConfigurations > >>> >> >> > >>> >> >> Best regards, > >>> >> >> Remko > >>> >> >> > >>> >> >> > >>> >> >> > >>> >> >> On Tue, Oct 29, 2013 at 9:58 AM, Mahesh Dilhan < > >>> >> [email protected] > >>> >> >> >wrote: > >>> >> >> > >>> >> >> > Hi All, > >>> >> >> > > >>> >> >> > i'm interested in learning on JMX monitoring in log4j2. > >>> >> >> > > >>> >> >> > As explained I was able to get the log4j2 'tab' > statusLogger > >>> child > >>> >> >> > tab > >>> >> >> in > >>> >> >> > JConsole with the initial logging statements. > >>> >> >> > > >>> >> >> > Note:version : 2.0.9beta > >>> >> >> > > >>> >> >> > log4j2.xml > >>> >> >> > > >>> >> >> > <?xml version="1.0" encoding="UTF-8"?> > >>> >> >> > > >>> >> >> > <!-- No need to set system property "Log4jContextSelector" to > >>> >> >> > any > >>> >> value > >>> >> >> > when using <asyncLogger> or <asyncRoot>. --> > >>> >> >> > > >>> >> >> > <Configuration status="debug"> > >>> >> >> > <Appenders> > >>> >> >> > <!-- Async Loggers will auto-flush in batches, so switch > off > >>> >> >> > immediateFlush. --> > >>> >> >> > <RandomAccessFile name="RandomAccessFile" > >>> >> >> > fileName="asyncWithLocation.log" > >>> >> >> > immediateFlush="false" append="false"> > >>> >> >> > <PatternLayout> > >>> >> >> > <Pattern>%d %p %class{1.} [%t] %location %m > >>> >> >> > %ex%n</Pattern> > >>> >> >> > </PatternLayout> > >>> >> >> > </RandomAccessFile> > >>> >> >> > > >>> >> >> > </Appenders> > >>> >> >> > <Loggers > > >>> >> >> > <!-- pattern layout actually uses location, so we need to > >>> >> >> > include > >>> >> >> > it > >>> >> >> > --> > >>> >> >> > <AsyncLogger name="notificationLogger" level="trace" > >>> >> >> > includeLocation="true"> > >>> >> >> > <AppenderRef ref="RandomAccessFile"/> > >>> >> >> > </AsyncLogger> > >>> >> >> > <Root level="debug" includeLocation="true"> > >>> >> >> > <AppenderRef ref="notificationLogger"/> > >>> >> >> > </Root> > >>> >> >> > </Loggers> > >>> >> >> > </Configuration> > >>> >> >> > > >>> >> >> > <!-- notificationLogger --> > >>> >> >> > private static Logger logger = > >>> >> >> LogManager.getLogger("notificationLogger"); > >>> >> >> > > >>> >> >> > > >>> >> >> > When web Application(java/servlet/spring) runs I can see the > >>> >> >> > file[asyncWithLocation.log] get appended with the logging > >>> >> >> > statements, > >>> >> >> > I like to see Jconsole get appended too, But It did not. > >>> >> >> > > >>> >> >> > > >>> >> >> > I wonder, what configuration I should use to enable jmx > logging, > >>> >> >> > so > >>> >> >> > that > >>> >> >> I > >>> >> >> > can see them in JConsole? > >>> >> >> > > >>> >> >> > is there any documentation other than this > >>> >> >> > http://logging.apache.org/log4j/2.x/manual/jmx.html, > >>> >> >> > > >>> >> >> > it would be great if above documentation is updated with a > >>> >> >> > sample > >>> of > >>> >> >> > log4j2.xml configuration. > >>> >> >> > > >>> >> >> > Thanks > >>> >> >> > > >>> >> >> > Mahesh > >>> >> >> > > >>> >> >> > >>> >> > > >>> >> > > >>> >> > > >>> >> > Mahesh > >>> >> > > >>> >> > >>> >> > --------------------------------------------------------------------- > >>> >> To unsubscribe, e-mail: [email protected] > >>> >> For additional commands, e-mail: [email protected] > >>> >> > >>> >> > >>> > > >>> > > >>> > -- > >>> > Mahesh > >>> > > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: [email protected] > >>> For additional commands, e-mail: [email protected] > >>> > >>> > >> > >> > >> -- > >> Mahesh > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Mahesh
