Can I do size based log rotation in bunyan and is max number of log files configurable in bunyan?

1,200 views
Skip to first unread message

Shubhra Sharma

unread,
Sep 15, 2014, 2:39:16 PM9/15/14
to bunyan-...@googlegroups.com
Hi All,

I'm new to bunyan and I'm looking at bunyan and winston for logging framework for our node.js based app.So far I am leaning towards bunyan. I see that log rotation is configurable by duration like "1d" etc but can it also be configured by file size? If yes, where can see some examples? Also can the max number of log files be configured?

Thanks,
Shubhra

Trent Mick

unread,
Sep 15, 2014, 3:57:48 PM9/15/14
to Shubhra Sharma, bunyan-...@googlegroups.com
Hi Shubhra,

Currently, no, you cannot control log rotation by log file *size* in Bunyan.
You can control the number of log files with the "count" field as documented here: https://github.com/trentm/node-bunyan#stream-type-rotating-file

Also, FWIW, I would encourage you to consider using your system's own log file rotation facilities instead of Bunyan's. Bunyan's can be convenient but, as you've noticed, it is comparatively limited. `logrotate` on Linux and `logadm` on SmartOS/illumos, etc. are quite featureful.

Cheers,
Trent

--
Trent Mick

Trent Mick

unread,
Sep 20, 2014, 4:56:17 PM9/20/14
to Shubhra Sharma, bunyan-...@googlegroups.com
Shubhra,

No, there currently isn't any support for loading a full logger config from a static file.

If you are interested there is a related discussion here: https://github.com/trentm/node-bunyan/issues/153
Though personally I don't see my adding support for this directly to Bunyan. In this comment (https://github.com/trentm/node-bunyan/issues/153#issuecomment-50948283) I suggested a separate module could easily provide something like this.

A reason I don't want this in core right now is that I think a way to define a logger config statically is something that should take time and experience to come up with a solution that works well. And that is best done in a separate module. If something solid and popular gets traction then I could see adopting that in core.

Cheers,
Trent

On Tue, Sep 16, 2014 at 11:23 AM, Shubhra Sharma <sharma.s...@gmail.com> wrote:
Hi Trent,

Thanks a lot for replying. I started playing with bunyan and I seem to like it so far. Quick question, is there a way for me to define all the properties in properties file something like a log4j.properties?


Basically something like this:

log4j.properties:

# log4j Properties file 

#


# Console appender

log4j.appender.console=org.apache.log4j.ConsoleAppender

log4j.appender.console.layout=org.apache.log4j.PatternLayout

log4j.appender.console.layout.ConversionPattern=%d|%-5p|%t|%c{1}.%M[%L] %m%n

#log4j.appender.console.layout.ConversionPattern=%t|%c{1}.%M %m%n

log4j.appender.console.threshold=WARN


#log4j.rootLogger=INFO, console

log4j.rootLogger=WARN, console


Thanks, 

Shubhra





--
Trent Mick
Reply all
Reply to author
Forward
0 new messages