More than one Logging configuration in yaml

1,911 views
Skip to first unread message

vinoth kumar Nagaraj

unread,
Nov 6, 2014, 8:38:57 AM11/6/14
to dropwiz...@googlegroups.com
Is there way to create multiple logging in yaml configuration. 

Dimas Guardado

unread,
Nov 6, 2014, 1:02:11 PM11/6/14
to dropwiz...@googlegroups.com
Hi Vinoth,

Are you looking to add multiple loggers/log levels, or multiple appenders/outputs, or something else entirely? The yaml configuration file allows configuration of both multiple loggers and multiple appenders. For loggers, you just need to add multiple name/level pairs, and for appenders you just add another entry to the appenders list.

An example of adding multiple appenders can be found in the project documentation, right after the syslog example:
http://dropwizard.io/manual/core.html#syslog-logging

Best,
Dimas

vinoth kumar Nagaraj

unread,
Nov 6, 2014, 1:25:46 PM11/6/14
to dropwiz...@googlegroups.com
Hi Dimas,
I agree we can create multiple level and we can separate different files...
My intend is to create two loggers
ex: 
logging:
  level: INFO
  appenders:
    - type: file
      threshold: INFO
      currentLogFilename: ./logs/example1.log

logging:
   level:INFO
   appenders:
      -type: file
       threshold: INFO
       currentLogFilename: ./logs/example2.log

can i able to create slf4j logger for these two INFO file
ex in 1. Logger log = LoggerFactory.getLogger();
        2, Logger log = LoggerFactory.getLogger();

Is there any way to achieve this. 

Thanks,
Vinoth

Dimas Guardado

unread,
Nov 6, 2014, 1:57:00 PM11/6/14
to dropwiz...@googlegroups.com
Hi Vinoth,

I think understand now, sorry for the confusion. Currently Dropwizard does not support adding multiple log configurations in this fashion, nor does it support dispatching particular loggers to different appenders (which is how I'd be inclined to tackle this with logback.xml). I believe Dropwizard assumes all log output not destined for the request log goes to the same place. I'm not sure that there's any way around this without modifying dropwizard.

There seems to be some discussion of this in the following pull request:

https://github.com/dropwizard/dropwizard/pull/567

Best,
Dimas

Tatu Saloranta

unread,
Nov 6, 2014, 4:03:07 PM11/6/14
to dropwiz...@googlegroups.com
On Thu, Nov 6, 2014 at 10:57 AM, Dimas Guardado <dimas.g...@gmail.com> wrote:
Hi Vinoth,

I think understand now, sorry for the confusion. Currently Dropwizard does not support adding multiple log configurations in this fashion, nor does it support dispatching particular loggers to different appenders (which is how I'd be inclined to tackle this with logback.xml). I believe Dropwizard assumes all log output not destined for the request log goes to the same place. I'm not sure that there's any way around this without modifying dropwizard.


Well, there's also the possibility of just re-configuring logback after DropWizard has initialized it.
You can still add your own configuration in yaml/json file, but despite its otherwise good functionality, logback didn't seem very easy to programmatically configure last I checked (which is a while ago).

So probably having your own logback config file/resource, and forcing loading of that after DW initialization is complete is the way to go on short term.

-+ Tatu +-
 

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages