You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.0 KiB
2.0 KiB
LINGYUN.Abp.Logging
Basic logging module
Defines the ILoggingManager interface for implementing log information queries.
Features
- Provides unified logging query interface ILoggingManager
- Supports various log field queries, including timestamp, log level, message, etc.
- Supports exception information recording and querying
- Supports rich log field information such as machine name, environment name, application name, etc.
- Supports pagination query and count statistics
Module Reference
[DependsOn(typeof(AbpLoggingModule))]
public class YouProjectModule : AbpModule
{
// other
}
Configuration
Configure in appsettings.json:
{
"Logging": {
"MachineName": "your-machine-name",
"EnvironmentName": "environment-name"
}
}
Basic Usage
- Inject ILoggingManager interface:
public class YourService
{
private readonly ILoggingManager _loggingManager;
public YourService(ILoggingManager loggingManager)
{
_loggingManager = loggingManager;
}
}
- Query logs:
// Get log list
var logs = await _loggingManager.GetListAsync(
startTime: DateTime.Now.AddDays(-1),
maxResultCount: 10,
skipCount: 0,
level: LogLevel.Error
);
// Get log count
var count = await _loggingManager.GetCountAsync(
startTime: DateTime.Now.AddDays(-1),
level: LogLevel.Error
);
// Get single log
var log = await _loggingManager.GetAsync(id);
Log Field Description
- TimeStamp - Log timestamp
- Level - Log level
- Message - Log message
- Fields - Log field information
- Id - Log unique identifier
- MachineName - Machine name
- Environment - Environment name
- Application - Application name
- Context - Context
- ActionId - Action ID
- ActionName - Action name
- RequestId - Request ID
- RequestPath - Request path
- ConnectionId - Connection ID
- CorrelationId - Correlation ID
- ClientId - Client ID
- UserId - User ID
- ProcessId - Process ID
- ThreadId - Thread ID
- Exceptions - Exception information list