Provides log functionality.
app.component.ts
import { LogService } from '@alfresco/adf-core';
@Component({...})
class AppComponent {
constructor(logService: LogService) {
}
myMethod(){
this.logService.error('My error');
this.logService.trace('My trace')
this.logService.debug('My debug')
this.logService.info('My info')
this.logService.warn('My warn')
}
}
import { LogService } from '@alfresco/adf-core';
@Component({...})
class AppComponent {
constructor(logService: LogService, myIntegrationService: MyIntegrationService)) {
logService.onMessage.subscribe((message) => {
myIntegrationService.send(message.text,message.type);
});
}
}
boolean
, message?: string
, optionalParams: any[]
)boolean
- (Optional) Test value (typically a boolean expression)string
- (Optional) Message to show if test is falseany[]
- Interpolation values for the message in "printf" formatany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatstring
): LogLevelsEnum
string
- Level nameLogLevelsEnum
- Numeric log levelstring
, optionalParams: any[]
)string
- (Optional) Title shown at the start of the groupany[]
- Interpolation values for the title in "printf" formatany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatstring
, logLevel: string
)string
- Message textstring
- Log level for the messageany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatany
, optionalParams: any[]
)any
- (Optional) Message to logany[]
- Interpolation values for the message in "printf" formatThere are 6 levels of logs that you can use:
Name | Level |
---|---|
TRACE | 5 |
DEBUG | 4 |
INFO | 3 |
WARN | 2 |
ERROR | 1 |
SILENT | 0 |
You can set the default log level using the logLevel property in app.config.json
.
The factory setting for this property is TRACE
.
For example, you can set the default log level to WARNING
as follows:
app.config.json
{
"logLevel": "WARN"
}
The log service also provides an
Observable
called _onMessage_
that you can subscribe to if you want to receive all the log messages.
The message object passed as a parameter to the onMessage
handler has the following format:
{ text: "Message log text" type: "ERROR|DEBUG|INFO|LOG|TRACE|WARN|ASSERT" }
You can pass the log output to an analytics system to collect error and assertion data from apps as they run. This can help you spot which problems users are running into most often and the situations in which they occur. See the tutorial about integrating the log service with analytics on the Alfresco Community site for further information.
© 2023 Alfresco Software, Inc. All Rights Reserved.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.