Skip to content

%f{depth} filename separator #1060

@crgmz

Description

@crgmz

Hello, it seems I can't get %f{depth} to work on my system (Windows 10, Node v14.15), here's a sample codeblock:

import log4js from 'log4js';

log4js.configure({
  appenders: {
    out: {
      type: 'console',
      layout: {
        type: 'pattern',
        pattern: '%d %f{1} %m',
      },
    },
  },
  categories: {
    default: { appenders: ['out'], level: 'info', enableCallStack: true },
  },
});

const logger = log4js.getLogger('app');

logger.info('Test log message');

Expected output:
2021-02-22T12:46:30.039 /main.js Test log message
Actual output:
2021-02-22T12:46:30.039 file:///C:/Users/Username/Desktop/Projects/Logtest/src/main.js Test log message

The issue seems to be in layouts.js because path.sep is (correctly) returning \, while filename is file:///C:/Users/Username/Desktop/Projects/Logtest/src/main.js, so the filename is never split.

Is this an OS and/or node misconfiguration on my part?

I managed to correct the issue by modifying layouts.js split separator parameter, I'll submit a fix PR in case this is a general issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions