Google News
logo
Aurelia - Interview Questions
What is Logging and how to Configuring Logging in Aurelia?
Logging : Aurelia has a simple logging abstraction that the framework itself uses. By default it is a no-op. The configuration in the above examples shows how to install an appender which will take the log data and output it to the console. Here's the code again, for convenience :
 
Configuring Logging : ES Next
import {LogManager} from 'aurelia-framework';
  import {ConsoleAppender} from 'aurelia-logging-console';
  
  LogManager.addAppender(new ConsoleAppender());
  LogManager.setLevel(LogManager.logLevel.debug);
  
  export function configure(aurelia) {
    aurelia.use
      .standardConfiguration;
  
    aurelia.start().then(() => aurelia.setRoot());
  }
 
Configuring Logging : TypeScript
import {LogManager, Aurelia} from 'aurelia-framework';
  import {ConsoleAppender} from 'aurelia-logging-console';
  
  LogManager.addAppender(new ConsoleAppender());
  LogManager.setLevel(LogManager.logLevel.debug);
  
  export function configure(aurelia: Aurelia): void {
    aurelia.use
      .standardConfiguration;
  
    aurelia.start().then(() => aurelia.setRoot());
  }
You can also see how to set the log level. Values for the logLevel include : none, error, warn, info and debug.
Advertisement