Hi there,
I was wondering if there is a way to turn off or reduce the logs that are generated by the application’s redux-actions in development environment. Especially when using input fields, the console gets flooded with logs.
(My application config is based on the current A12 template.)
Best Regards,
Alex (<PROJECT_NAME> team)
The easiest way to change the logging level is to add the following to your configuration or setup file.
import { ConsoleLoggingStrategy } from "@com.mgmtp.a12/logging";
import { LogLevel } from "@com.mgmtp.a12/logging/api";
import { Container } from "../../../src/core/configuration";
Container.config.bind(Container.identifier.LoggingStrategy).toConstantValue(
new ConsoleLoggingStrategy(console, LogLevel.WARN)
);
By default the log level WARN is used.
In case you use the template providing from us the log level is set to LOG in the config file (template/src/config/dev.config.ts).
Another option is to replace or configure the logging strategy more deeply. For example the ConsoleLoggingStrategy provide additional options like outputNamespace or filterNamespace.
/**
* Like BaseConsoleLoggingStrategy but with additional awareness of a minimum log level.
*
* @export
* @class ConsoleLoggingStrategy
* @extends {MinLogLevelLoggingStrategy}
* @see {BaseConsoleLoggingStrategy}
*/
export declare class ConsoleLoggingStrategy extends MinLogLevelLoggingStrategy {
constructor(console: Console, logLevel?: LogLevel, options?: ConsoleOptions);
}
/**
* Options for the console logging strategy
*
* @export
* @interface ConsoleOptions
*/
export interface ConsoleOptions {
/**
* Pass a boolean or a callback function to hint the strategy whether
* the namespace should be passed to Console before the message or not.
*
* Please note that in case the callback function invocation results in an error,
* the implementation will resort to its default value, which is "true".
*
* @memberof ConsoleOptions
*/
outputNamespace?: boolean | ((ns: string) => boolean);
/**
*
* Pass a function, a single namespace or a list of namespaces to specify which namespaces should be omitted.
*
* @memberof ConsoleOptions
*/
filterNamespace?: ((ns: string, level: LogLevel) => boolean) | string | string[];
}
For more information please consult the @com.mgmtp.a12/logging documentation.
Thanks so much, found it in ‘src/config/dev.config.ts’ in the A12 template.