Skip to content

Nestjs example #519

@nushrivastava

Description

@nushrivastava

Can you share a nestjs example in your usage along with the currently shared test scenarios. I have already configured log4js, but I needed nest system logs to be pushed to my configured logger for which I came across this library, but I am not able to configure it correctly.
I have added the suggested code of app.use(app.get(Log4jsModule)) in main.ts and in my app.module file I am trying to do

Log4jsModule.forRoot({
      config: {
        appenders: {
          analyticsFileAppender: {
            type: 'file',
            maxLogSize: environment.maxLogSize,
            keepFileExt: true,
            layout: {
              type: 'pattern',
              pattern: '%d %p %z %f{1}:%l %m%n',
            },
            filename: `${environment.logDir}/${environment.logFile}`,
          },
          analyticsConsoleAppender: {
            type: 'console',
            layout: {
              type: 'pattern',
              pattern: '%d %p %z %f{1}:%l %m%n',
            },
          },
        },

        categories: {
          default: {
            appenders: [`${environment.appender}`],
            level: `${environment.logLevel}`,
            enableCallStack: true,
          },
        },
      },
    }),

These configurations I have added to my nest library and simply exported getLogger() value, while trying to reuse the config from there I was not able to use it. Even after hard coding it like above it gives me error

if (category.indexOf('.') > 0) {
               ^
TypeError: category.indexOf is not a function

I have even tried to put the basic config that you have added in your test example usage but stuck with the same issue.

If I only use Log4jsModule.forRoot() I am able to make it work, but it doesnt use my existing logger configurations. (Obviously, but wanted to state that with default it works.)
Online support of this library is very less, due to which I am posting this question here, Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions