You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Fabrizio Giudici <fa...@tidalwave.it> on 2008/02/07 14:13:38 UTC
Customizing logging
Ok, that's really silly. In my application I use java.util.logging
(and I need/want to use it, since some external components use it).
For all the projects I've developed in every contest, from JSP to JSF
to Swing etc... I've always used a custom logging formatter that puts
every event in a single line (grep friendly) and with specific tabs
that I've got acquainted to use and allow me to inspect thousands of
lines in a very short time.
So far, I wasn't able to install it in my Wicket application.
This is what I have in my WebApplications subclass that gets
initialized at startup:
private void setupLogging ()
{
try
{
InputStream is = getClass().getResourceAsStream("/
log.properties");
LogManager.getLogManager().readConfiguration(is);
is.close();
final PlainLogFormatter formatter = new PlainLogFormatter
();
Logger rootLogger = Logger.getLogger(CLASS);
while (rootLogger.getParent() != null)
{
rootLogger = rootLogger.getParent();
}
for (final Handler handler : rootLogger.getHandlers())
{
handler.setFormatter(formatter);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
Indeed, log.properties is read and evaluated, in fact I can control
the logging levels etc. I can configure everything BUT the formatter.
If I specify it, I get the nigthmare XML formatter.
Even the code that navigates the loggers and manually sets the
formatter doesn't work (for instance, I use it in a NetBeans RCP
application where I know that the formatter can't be applied for
classloader issues). But here it doesn't work. This is somewhat a
minor issue, but now that I'm doing the final polishing I'd like to
have logs like I want to see :-)
Thanks.
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
Re: Customizing logging
Posted by Igor Vaynberg <ig...@gmail.com>.
weird. i dont use jdk logging so i dont think i will be able to help
you much. perhaps you should set a breakpoint on
handler.setFormatter() and see if anything else calls it _after_ your
code has executed.
-igor
On Feb 7, 2008 11:41 AM, Fabrizio Giudici <fa...@tidalwave.it> wrote:
>
> On 07/feb/08, at 20:36, Igor Vaynberg wrote:
>
> > do you have slf4j adapter for jdk logging jar?
> >
> > http://www.slf4j.org/api/org/slf4j/impl/JDK14LoggerAdapter.html
>
> Yes, I've added it when I upgraded to 1.3.0 (I bet that without it I
> wouldn't have any logging at all from Wicket). But I always had that
> problem, since when I started developing with 1.2.
>
>
> >
> > -igor
> >
> >
> > On Feb 7, 2008 5:13 AM, Fabrizio Giudici
> > <fa...@tidalwave.it> wrote:
> >> Ok, that's really silly. In my application I use java.util.logging
> >> (and I need/want to use it, since some external components use it).
> >> For all the projects I've developed in every contest, from JSP to JSF
> >> to Swing etc... I've always used a custom logging formatter that puts
> >> every event in a single line (grep friendly) and with specific tabs
> >> that I've got acquainted to use and allow me to inspect thousands of
> >> lines in a very short time.
> >>
> >> So far, I wasn't able to install it in my Wicket application.
> >>
> >> This is what I have in my WebApplications subclass that gets
> >> initialized at startup:
> >>
> >> private void setupLogging ()
> >> {
> >> try
> >> {
> >> InputStream is = getClass().getResourceAsStream("/
> >> log.properties");
> >> LogManager.getLogManager().readConfiguration(is);
> >> is.close();
> >>
> >> final PlainLogFormatter formatter = new
> >> PlainLogFormatter
> >> ();
> >> Logger rootLogger = Logger.getLogger(CLASS);
> >>
> >> while (rootLogger.getParent() != null)
> >> {
> >> rootLogger = rootLogger.getParent();
> >> }
> >>
> >> for (final Handler handler : rootLogger.getHandlers())
> >> {
> >> handler.setFormatter(formatter);
> >> }
> >> }
> >> catch (Exception e)
> >> {
> >> e.printStackTrace();
> >> }
> >> }
> >>
> >> Indeed, log.properties is read and evaluated, in fact I can control
> >> the logging levels etc. I can configure everything BUT the formatter.
> >> If I specify it, I get the nigthmare XML formatter.
> >>
> >> Even the code that navigates the loggers and manually sets the
> >> formatter doesn't work (for instance, I use it in a NetBeans RCP
> >> application where I know that the formatter can't be applied for
> >> classloader issues). But here it doesn't work. This is somewhat a
> >> minor issue, but now that I'm doing the final polishing I'd like to
> >> have logs like I want to see :-)
> >>
> >> Thanks.
> >>
> >>
> >>
> >> --
> >> Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
> >> Tidalwave s.a.s. - "We make Java work. Everywhere."
> >> weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
> >> Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> --
>
> Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
> Tidalwave s.a.s. - "We make Java work. Everywhere."
> weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
> Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Customizing logging
Posted by Fabrizio Giudici <fa...@tidalwave.it>.
On 07/feb/08, at 20:36, Igor Vaynberg wrote:
> do you have slf4j adapter for jdk logging jar?
>
> http://www.slf4j.org/api/org/slf4j/impl/JDK14LoggerAdapter.html
Yes, I've added it when I upgraded to 1.3.0 (I bet that without it I
wouldn't have any logging at all from Wicket). But I always had that
problem, since when I started developing with 1.2.
>
> -igor
>
>
> On Feb 7, 2008 5:13 AM, Fabrizio Giudici
> <fa...@tidalwave.it> wrote:
>> Ok, that's really silly. In my application I use java.util.logging
>> (and I need/want to use it, since some external components use it).
>> For all the projects I've developed in every contest, from JSP to JSF
>> to Swing etc... I've always used a custom logging formatter that puts
>> every event in a single line (grep friendly) and with specific tabs
>> that I've got acquainted to use and allow me to inspect thousands of
>> lines in a very short time.
>>
>> So far, I wasn't able to install it in my Wicket application.
>>
>> This is what I have in my WebApplications subclass that gets
>> initialized at startup:
>>
>> private void setupLogging ()
>> {
>> try
>> {
>> InputStream is = getClass().getResourceAsStream("/
>> log.properties");
>> LogManager.getLogManager().readConfiguration(is);
>> is.close();
>>
>> final PlainLogFormatter formatter = new
>> PlainLogFormatter
>> ();
>> Logger rootLogger = Logger.getLogger(CLASS);
>>
>> while (rootLogger.getParent() != null)
>> {
>> rootLogger = rootLogger.getParent();
>> }
>>
>> for (final Handler handler : rootLogger.getHandlers())
>> {
>> handler.setFormatter(formatter);
>> }
>> }
>> catch (Exception e)
>> {
>> e.printStackTrace();
>> }
>> }
>>
>> Indeed, log.properties is read and evaluated, in fact I can control
>> the logging levels etc. I can configure everything BUT the formatter.
>> If I specify it, I get the nigthmare XML formatter.
>>
>> Even the code that navigates the loggers and manually sets the
>> formatter doesn't work (for instance, I use it in a NetBeans RCP
>> application where I know that the formatter can't be applied for
>> classloader issues). But here it doesn't work. This is somewhat a
>> minor issue, but now that I'm doing the final polishing I'd like to
>> have logs like I want to see :-)
>>
>> Thanks.
>>
>>
>>
>> --
>> Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
>> Tidalwave s.a.s. - "We make Java work. Everywhere."
>> weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
>> Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
Re: Customizing logging
Posted by Igor Vaynberg <ig...@gmail.com>.
do you have slf4j adapter for jdk logging jar?
http://www.slf4j.org/api/org/slf4j/impl/JDK14LoggerAdapter.html
-igor
On Feb 7, 2008 5:13 AM, Fabrizio Giudici <fa...@tidalwave.it> wrote:
> Ok, that's really silly. In my application I use java.util.logging
> (and I need/want to use it, since some external components use it).
> For all the projects I've developed in every contest, from JSP to JSF
> to Swing etc... I've always used a custom logging formatter that puts
> every event in a single line (grep friendly) and with specific tabs
> that I've got acquainted to use and allow me to inspect thousands of
> lines in a very short time.
>
> So far, I wasn't able to install it in my Wicket application.
>
> This is what I have in my WebApplications subclass that gets
> initialized at startup:
>
> private void setupLogging ()
> {
> try
> {
> InputStream is = getClass().getResourceAsStream("/
> log.properties");
> LogManager.getLogManager().readConfiguration(is);
> is.close();
>
> final PlainLogFormatter formatter = new PlainLogFormatter
> ();
> Logger rootLogger = Logger.getLogger(CLASS);
>
> while (rootLogger.getParent() != null)
> {
> rootLogger = rootLogger.getParent();
> }
>
> for (final Handler handler : rootLogger.getHandlers())
> {
> handler.setFormatter(formatter);
> }
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
>
> Indeed, log.properties is read and evaluated, in fact I can control
> the logging levels etc. I can configure everything BUT the formatter.
> If I specify it, I get the nigthmare XML formatter.
>
> Even the code that navigates the loggers and manually sets the
> formatter doesn't work (for instance, I use it in a NetBeans RCP
> application where I know that the formatter can't be applied for
> classloader issues). But here it doesn't work. This is somewhat a
> minor issue, but now that I'm doing the final polishing I'd like to
> have logs like I want to see :-)
>
> Thanks.
>
>
>
> --
> Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
> Tidalwave s.a.s. - "We make Java work. Everywhere."
> weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
> Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org