- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Send logs to Datadog from your Flutter applications with Datadog’s flutter plugin and leverage the following features:
To initialize the Datadog Flutter SDK for Logs, see Setup.
Once you have initialized the Datadog Flutter SDK with a LoggingConfiguration
parameter, you can create a DatadogLogger
and send logs to Datadog.
final logConfiguration = DatadogLoggerConfiguration(
remoteLogThreshold: LogLevel.debug,
networkInfoEnabled: true,
);
final logger = DatadogSdk.instance.logs?.createLogger(logConfiguration);
logger?.debug("A debug message.");
logger?.info("Some relevant information?");
logger?.warn("An important warning…");
logger?.error("An error was met!");
You can create additional loggers with different services and names using the createLogger
method as well:
final myLogger = DatadogSdk.instance.logs?.createLogger(
DatadogLoggerConfiguration(
service: 'com.example.custom_service',
name: 'Additional logger'
)
);
myLogger?.info('Info from my additional logger.');
For more information about available logging options, see the DatadogLoggerConfiguration class documentation.
Tags set on loggers are local to each logger.
Use the DatadogLogger.addTag
method to add tags to all logs sent by a specific logger:
// This adds a "build_configuration:debug" tag
logger.addTag("build_configuration", "debug")
Use the DatadogLogger.removeTag
method to remove tags from all logs sent by a specific logger:
// This removes any tag that starts with "build_configuration"
logger.removeTag("build_configuration")
For more information, see Getting Started with Tags.
Attributes set on loggers are local to each logger.
By default, the following attributes are added to all logs sent by a logger:
http.useragent
and its extracted device
and OS
propertiesnetwork.client.ip
and its extracted geographical properties (country
, city
)logger.version
, Datadog SDK versionlogger.thread_name
, (main
, background
)version
, client’s app version extracted from either the Info.plist
or application.manifest
environment
, the environment name used to initialize the SDKUse the DatadogLogger.addAttribute
method to add a custom attribute to all logs sent by a specific logger:
logger.addAttribute("user-status", "unregistered")
The value
can be most types supported by the StandardMessageCodec
class.
Use the DatadogLogger.removeAttribute
method to remove a custom attribute from all logs sent by a specific logger:
// This removes the attribute "user-status" from all logs sent moving forward.
logger.removeAttribute("user-status")
By default, for debug builds, DatadogLogger
s print all logs to the Flutter console in the format:
[{level}] message
This can be customized by setting a DatadogLoggerConfiguration.customConsoleLogFunction
. To filter logs below a certain level, set this to simpleConsolePrintForLevel
:
final config = DatadogLoggerConfiguration(
// Other configuration options...
customConsoleLogFunction: simpleConsolePrintForLevel(LogLevel.warn),
);
You can also forward Datadog logs to other log packages, such as logger, by supplying a custom function:
var Logger logger;
void customDatadogLog(LogLevel level,
String message,
String? errorMessage,
String? errorKind,
StackTrace? stackTrace,
Map<String, Object?> attributes,) {
// Assuming you have a Logger and custom level mapping function:
logger.log(mapLogLevels(level), message, error: errorKind, stackTrace: stackTrace);
}
final datadogLogger = DatadogSdk.instance.logs?.createLogger(
DatadogLoggerConfiguration(
// Other configuration options...
customConsoleLogFunction: simpleConsolePrintForLevel(LogLevel.warn),
);
);
추가 유용한 문서, 링크 및 기사: