Coder Social home page Coder Social logo

Comments (14)

zoell avatar zoell commented on June 18, 2024 17

Is it possible to add this feature so the current log file is alone without the date and it will rotate on date also?

So like:
current: the_log_file.log
yesterday: the_log_file.log..2017-02-07
etc?

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024 1

I believe you should be able to set date format to '.log'.

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024 1

@bitsofinfo to close the loop on this: the following code should get you what you're requesting:

var fileTransportOpts = {
  filename: './server',
  datePattern: '.log'
};

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.DailyRotateFile)(fileTransportOpts)
  ]
});

logger.log('info', 'test message');

The last line will create a file called server.log in the current folder. Please re-open if this doesn't meet your needs.

from winston-daily-rotate-file.

Rychu-Pawel avatar Rychu-Pawel commented on June 18, 2024 1

datePatern has to be inside square brackets these days and without the dot so the correct workaround is now

var fileTransportOpts = {
  filename: './server',
  datePattern: '[log]'
};

from winston-daily-rotate-file.

bitsofinfo avatar bitsofinfo commented on June 18, 2024

That results in: overwatch-sample-1.log..log

Setting to just log = overwatch-sample-1.log.log

Will this still properly do rotation with this setting?

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024

Please provide the code you're using. Im unable to reproduce. The sample I posted above creates appropriately named log files. Make sure that you're specifying filename properly. In your case, it looks like you want filename: 'overwatch-sample' and datePattern: '.log'.

from winston-daily-rotate-file.

bitsofinfo avatar bitsofinfo commented on June 18, 2024

Yeah when I did that the name is as expected, my other question is still the main question:

Will this still properly do rotation with this setting?

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024

I would expect it to rotate, assuming you have maxsize set. Obviously, it wouldn't rotate on date. Please let me know if you see different behavior.

from winston-daily-rotate-file.

bitsofinfo avatar bitsofinfo commented on June 18, 2024

Ok, if it won't do the date based rotation, not much point in using it. I really think this should support the option of the current log file having no suffix and only older log files having the date.

from winston-daily-rotate-file.

sumitjainn avatar sumitjainn commented on June 18, 2024

Please reopen the issue.. it would be really useful if it supports both: current file without date suffix and date based log rotation.

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024

@sumitjainn the transport supports date-based log rotation. For the other piece of your request, follow #23.

from winston-daily-rotate-file.

shivang2joshi avatar shivang2joshi commented on June 18, 2024

@sumitjainn you can add two separate transports. one logs into current.log, second with DailyRotateFile support. Add some memory limit for current.log

from winston-daily-rotate-file.

galamo avatar galamo commented on June 18, 2024

Hi
is this issue solved? is there a configuration for winston to apply this behaviour ?

So like:
current: the_log_file.log
yesterday: the_log_file.log..2017-02-07
etc?

from winston-daily-rotate-file.

mattberther avatar mattberther commented on June 18, 2024

Try the configuration at #310, @galamo. The logs files will always have a timestamp on them, as defined by the datePattern option. However, if you need a tailable file, you can use the symlink options described in that issue (and in the README).

from winston-daily-rotate-file.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.