question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syslog level 'debug' not showing up

See original GitHub issue

Hi, I’m trying to use Winston to automate my logging for an internship’s project. I’ve just noticed that the debug logs don’t show up, though I use the same method as for ‘info’, ‘warn’ and ‘error’ (which are perfectly displayed for what I need).

Here is my code:

var winston = require('winston');
var dateFormat = require('dateformat');

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)({
      timestamp: function() {
        var now = new Date();
        return dateFormat(now, "isoDateTime");
      },
      formatter: function(options) {
        // Return string will be passed to logger.
        return options.timestamp() + options.level.toUpperCase() + ' ' + (options.message == undefined ? "-" : options.message);
      }
    })
  ]
});

logger.setLevels(winston.config.syslog.levels);
winston.addColors(winston.config.syslog.colors);

module.exports = {
  /**
  * Log debuging messages
  * @param  {String} message
  */
  debug: function(message) {
    logger.log('debug','Data to log.');
  },
  /**
  * Log information messages
  * @param  {String} message
  */
  info: function(message) {
    logger.log('info','Data to log.');
  },
  /**
  * Log warning messages
  * @param  {String} message
  */
  warn: function(message) {
    logger.log('warn','Data to log.');
  },
  /**
  * Log error messages
  * @param  {String} message
  */
  error: function(message) {
    logger.log('error','Data to log.');
  }
};

Runnung a test.js like:

var logger = require('./logger.js');

logger.debug('test');
logger.info('test');
logger.warn('test');
logger.error('test');

Gives me only the following output:

2016-04-08T18:47:26+0200 INFO test
2016-04-08T18:47:26+0200 WARN test
2016-04-08T18:47:26+0200 ERROR test

Am I doing something wrong or does it comes from Winston?

Infos: The probem is the same on windows and linux:

  • On linux
$ node -v
v0.10.42
  • On windows:
> node -v
v5.10.1

Replacing logger.setLevels(winston.config.syslog.levels); with winston.setLevels(winston.config.syslog.levels); doesn’t change anything.

And adding a console.dir(winston.config.syslog.levels) gives me the following object (that seems good to me…):

{
  levels:
  {
    emerg: 0,
    alert: 1,
    crit: 2,
    error: 3,
    warning: 4,
    notice: 5,
    info: 6,
    debug: 7
  },
  colors:
  {
    emerg: 'red',
    alert: 'yellow',
    crit: 'red',
    error: 'red',
    warning: 'red',
    notice: 'yellow',
    info: 'green',
    debug: 'blue'
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

23reactions
Cobraeticommented, Apr 11, 2016

I’m sorry, I’ve just found that the mimum level for logs was something to set. It seems that the default level for syslog is ‘info’, so ‘debug’ entries were not displayed. So it was not an issue, just a lack of reading ^^ I hope that my mistake will at least help others realize this detail faster…

6reactions
Cobraeticommented, Dec 10, 2017

This test works on my Docker environment (see this page, I use alpine tag so Node version 9.2.1):

var winston = require('winston');
const logger = new (winston.Logger)({
        transports: [
                new winston.transports.Console({ level: 'debug' })
        ]
});
logger.log('debug',"Test");

The NPM page helped me write this short code, hope this could help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

syslog not showing log levels in messages - Ask Ubuntu
1 Answer 1 · open with admin privileges the file /etc/rsyslog.conf and add the following lines $template precise,"%syslogpriority%,% ...
Read more >
Troubleshooting Syslog-ng (4278280) - One Identity Support
You can turn on debug logging on a running syslog-ng instance ... Press CTRL + C to terminate syslog-ng, if it was not...
Read more >
GSLog : Logging not showing on syslog - ServiceNow
Setting the log level for an application to error generates error messages only, but does not generate warn, info, or debug messages.
Read more >
Change ESXI 6.5 Syslog level from debug to info
Hi, I have configured syslog logging for my ESXI 6.5 hosts. I have configured loglevel info for all syslog/vxa related entries in advanced ......
Read more >
"logging trap debugging" does not generate debug level ...
I have setup a syslog server to collect messages from several devices including routers, switches and PIX firewall. All configurations at syslog server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found