Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding header lines to logfiles in File and DailyRotateFile transport #691

Closed
alinex opened this issue Aug 14, 2015 · 1 comment
Closed

Comments

@alinex
Copy link

alinex commented Aug 14, 2015

I want to have a logfile header consisting of some comment lines explaining the used format (own formatter funtion).

I tried to use the open event but that is fired too late. I only don't know if it is fired on each file open (not as good) or if a new file is started (better),

My solution so far looks like (CoffeeScript);

trans = new winston.transports.DailyRotateFile  # or File
  level: 'info'
  filename: "#{__dirname}/log/#{filename}"
  formatter: myFormatter
trans.on 'open', ->
  trans._stream.write "# MY LOGFILE HEADER\n"
logger = new winston.Logger
  transports: [trans]

If I run this I will get:

INFO the real log entry
# MY LOGFILE HEADER
INFO another entry
INFO another entry

You see this comes one line too late.

Have you a better solution?

@indexzero
Copy link
Member

The DailyRotateFile transport was moved to a separate module (winston-daily-rotate-file) as of winston@2.0.0. As such we are closing issues here and tracking their status in a single tracking issue in the new repository.

Please open a new issue on winston-daily-rotate-file to continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants