Custom logger and console.log output
See original GitHub issueHi,
I have implemented a custom logger and it arrives there. I wanted to do all my logging in my custom logger because i dont want any output to the console. Right now i am seeing…
ngx-logger.js:228 2018-10-31T14:18:45.675Z ERROR [main.js:4864] THIS WAS ERROR
2018-10-31T14:18:51.650Z INFO [main.js:4866] THIS WAS INFO
ngx-logger is logging to the console, is it possible to turn this off ?
I have my custom logger
import { NGXLoggerMonitor, NGXLogInterface, Levels } from "ngx-logger"
export class MyLoggerMonitor implements NGXLoggerMonitor {
onLog(log: NGXLogInterface) {
debugger
//console.log("myCustomLoggerMonitor", log)
}
}
and my main logger service, where I inject NGXlogger
constructor(private logger: NGXLogger) {
this.logger.registerMonitor(new MyLoggerMonitor())
this.logger.updateConfig({ level: NgxLoggerLevel.INFO })
this.logger.error("THIS WAS ERROR")
this.logger.debug("THIS WAS DEBUG")
this.logger.info("THIS WAS INFO")
I basically have wrapping methods ie…
debug(message: string, ...additional: any[]) {
this.logger.debug(message, additional)
}
info(message: string, ...additional: any[]) {
this.logger.info(message, additional)
}
and I set this up in my core module -imports, like so
LoggerModule.forRoot({ level: NgxLoggerLevel.OFF })
As I say, it does work, it arrives inside my custom logger when I do a logger.info for example BUT the it still does a console.log
Can this be turned off in production, I can’t set the log level to OFF as then my custom logger doesn’t get activated.
Any ideas - thanks in advance
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Console log formatting - .NET - Microsoft Learn
Learn how to use available console log formatting, or implement custom log formatting for your .NET applications.
Read more >Organize Your JavaScript Console Logging with a Custom ...
In Example # 2, we have created a variable named “debugMode”. This tells our custom debug function whether or not messages should be...
Read more >Node.js Logging Tutorial - Stackify
In the built-in Node.js console log, all logging levels equate to either log ... When the output is the console or stdout/stderr, it...
Read more >Custom log messages - Sails.js
Custom log messages ... Like console.log , data passed as arguments to the Sails logger are ... Writes log output to stderr at...
Read more >Extending console.log without affecting log line - Stack Overflow
Some of the other answers here came close, but the trick is to have your custom logging method return the modified logger. Below...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
great, that works for me. Thanks
@appsolutegeek, this is by design. Updated the config is meant to completely overwrite the current config. We want to be explicit. There would be ambiguity if we were to just extend the config.
We do provide a method called
getConfigSnapshot()
, so if you wanted to update a single value, you could just