[2.0] How to specify logging levels per class or other functional area?

82 views
Skip to first unread message

Kenner Stross

unread,
Feb 14, 2012, 12:15:24 PM2/14/12
to play-fr...@googlegroups.com
First, congratulations to the Play team on getting 2.0 (almost) out the door!

I'm having trouble with (or am confused about) configuring the logger with different levels for different areas of my app.  What I'd like to do is be able to specify something like this in my application.conf file:

logger.myPkg.myClass=DEBUG
or...
logger.functionalArea=DEBUG
or...
something to indicate that this one slice has a different logging level than the application's overall level.

By reading the source code for the play.api.Logger object, it would seem like I should be able to get the associated logger by using the apply method:

Logger("functionalArea").debug("my message")

But I have not been able to get that to succeed using any combination of values that I can think of.  It does, however, work if I pass in:

Logger("application").debug("my message")

Which is, of course, retrieving the default application-level logger.  Why does it work for that, but not for any of my "custom" logging levels?  What am I overlooking?

Thanks,
Kenner


Guillaume Bort

unread,
Feb 15, 2012, 6:27:23 AM2/15/12
to play-fr...@googlegroups.com
Hum, works for me:

in conf/application.conf

logger.functionalArea=DEBUG

and then:

Logger("functionalArea").debug("BAM")

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/lybYDMJp_o8J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Henry Story

unread,
Mar 11, 2012, 12:48:22 PM3/11/12
to play-fr...@googlegroups.com
Same question really, but how does one do set logging levels from the console? This is something that
I can see being often useful: you debug something and want to just have full trace level on a few classes.

This sbt command does not seem to have any effect

  [myfirstapp] $ set logLevel in run := Level.Debug 

Well it coud be that I set my loggers to the Trace Level.

Guillaume Bort

unread,
Mar 11, 2012, 9:13:42 PM3/11/12
to play-fr...@googlegroups.com
Yes it would be interesting I agree, but currently the Play runtime
logger is slf4j (using logback), that is completely disconnected from
sbt.

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/play-framework/-/-TRl8xh9LUcJ.

Reply all
Reply to author
Forward
0 new messages