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

How to customise log file name #1039

Closed
aadgithub opened this issue Aug 7, 2020 · 3 comments · Fixed by #1135
Closed

How to customise log file name #1039

aadgithub opened this issue Aug 7, 2020 · 3 comments · Fixed by #1135
Labels
dependencies Pull requests that update a dependency file
Milestone

Comments

@aadgithub
Copy link

aadgithub commented Aug 7, 2020

Hi
I am using log4js version 6.2.1

I have configure logs level with following way in json file.
{ "appenders": { "Application": { "type": "dateFile", "filename": "logs/Application", "alwaysIncludePattern": true, "category": "Application", "layout": { "type": "pattern", "pattern": "<log timestamp=\"%d{yyyy-MM-dd hh:mm:ss.SSS}\" level=\"%5.5p\"><message>%m</message></log>" } }, "Database": { "type": "dateFile", "filename": "logs/Database", "alwaysIncludePattern": true, "category": "Database", "layout": { "type": "pattern", "pattern": "<log timestamp=\"%d{yyyy-MM-dd hh:mm:ss.SSS}\" level=\"%5.5p\"><message>%m</message></log>" } } } }

it is creating logs files daily with default name pattern like
Application.2020-08-07
Database.2020-08-07

I want to create file name with hyphen, like
Application-2020-08-07
Database-2020-08-07

is there any configuration to use custom file name?

@rnd-debug
Copy link
Contributor

rnd-debug commented Aug 12, 2020

@aadgithub Hello. Have you checked the pattern parameter of the appender configuration: https://log4js-node.github.io/log4js-node/dateFile.html ?
Something like:

    "Application": {
      "type": "dateFile",
      "filename": "logs/Application",
      "pattern": "-yyyy-MM-dd",               // <= check this
      "alwaysIncludePattern": true,
      "category": "Application",
      "layout": {...}
    },

@lamweili
Copy link
Contributor

lamweili commented Jan 6, 2022

"pattern": "-yyyy-MM-dd", will result in Application.-2020-08-07 instead of Application-2020-08-07.
There is an additional . separator, despite not being declared in the pattern.

There is a separate issue on that: log4js-node/streamroller#64

@lamweili lamweili added this to the 6.4.0 milestone Jan 12, 2022
@lamweili lamweili added the dependencies Pull requests that update a dependency file label Jan 19, 2022
@lamweili
Copy link
Contributor

lamweili commented Jan 19, 2022

It was fixed in streamroller@^3.0.0.

For more details: log4js-node/streamroller#75 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants