DataWeaveScriptingEngine engine = new DataWeaveScriptingEngine();
engine.withLoggingConfigurationSourceProvider(
  new DefaultLoggingConfigurationSourceProvider("classpath://org/acme/my-log-config.json")
);DataWeave Logging Configuration
Get granular control over DataWeave logging to debug and monitor your data transformations with precision.
Starting with DataWeave 2.10, you can configure logging to control the verbosity of log messages using standard log levels: Debug, Info, Warn, and Error. You can filter log messages by severity and scope, which makes it easier to troubleshoot and monitor your DataWeave code.
Configuration Location
Define the logging configuration in a DataWeave language file named log-config.dwl. Place this file in the classpath at the root level.
Use the DataWeaveScriptingEngine API to customize the name, location, and format of the configuration file by either implementing the LoggingConfigurationSourceProvider interface or by using the  DefaultLoggingConfigurationSourceProvider helper class.
| The DataWeaveScriptingEngineAPI is available only when running DataWeave outside of Mule runtime. If you’re using Mule runtime, configure logging only with thelog-config.dwlfile and, if needed, thelog4j2.xmlconfiguration file. | 
The DataWeave code in this example retrieves the logging configuration in JSON format from a custom classpath location.
Configuration Structure
The log-config.dwl file contains an array of objects. Each object defines a logging rule with these properties:
| Property | Description | Required for Scope | Possible Values | 
|---|---|---|---|
| 
 | Specifies the scope of the logging rule. | Always required | 
 | 
| 
 | Specifies the log level. | Always required | 
 | 
| 
 | Specifies the name of the DataWeave module. | Optional but required for  | Any valid DataWeave module name | 
| 
 | Specifies the name of the DataWeave function within the specified module. | Optional but required for  | Any valid DataWeave function name | 
Example: Configuring Log Levels
This configuration sets three logging rules. The first rule sets the default log level for the entire runtime to Warn, so only Warn and Error messages are logged unless a more specific rule overrides it. The second rule sets the log level for the module MyModule to Info, which overrides the runtime level and logs Info, Warn, and Error messages for all functions in MyModule. The third rule sets the log level for the function test in MyModule to Debug, which overrides both the module and runtime levels and logs all messages for this function.
[
  {
    scope: "Runtime",
    level: "Warn"
  },
  {
    scope: "Module",
    module: "MyModule",
    level: "Info"
  },
  {
    scope: "Function",
    module: "MyModule",
    function: "test",
    level: "Debug"
  }
]DataWeave Logging Functions
The DataWeave Core library provides these functions for logging messages:
| Function | Description | 
|---|---|
| 
 | Base function that provides the most flexibility. It takes a log level, an optional prefix, and a value to log, and returns the value. | 
| 
 | Logs a message with the  | 
| 
 | Logs a message with the  | 
| 
 | Logs a message with the  | 
| 
 | Logs a message with the  | 
| 
 | Logs a message with the  | 
Considerations
- 
Place the log-config.dwlfile in the classpath for the configuration to take effect.
- 
Log levels are hierarchical. Erroris the highest level, followed byWarn,Info, andDebug.
- 
More specific rules (for example, function-level rules) override less specific ones (for example, runtime-level rules). 
- 
Use the prefixparameter in log functions to add context to your log messages.
- 
In Mule runtime, the default logging level shows only WarnandErrormessages.To enable more detailed messages ( InfoorDebug), add a custom logger entry to yourlog4j2.xmlconfiguration file in the$MULE_HOME/conf/directory.To enable Debuglogging for DataWeave messages, add a custom logger entry to yourlog4j2.xmlconfiguration file:<AsyncLogger name="org.mule.weave.v2.model.service.DefaultLoggingService$" level="DEBUG"/>



