|
| 1 | +--- |
| 2 | +title: InfrastructureLogging |
| 3 | +sort: 20 |
| 4 | +contributors: |
| 5 | + - snitin315 |
| 6 | +--- |
| 7 | + |
| 8 | +Options for infrastructure level logging. |
| 9 | + |
| 10 | +## infrastructureLogging.appendOnly |
| 11 | + |
| 12 | +<Badge text="5.31.0+" /> |
| 13 | + |
| 14 | +`boolean` |
| 15 | + |
| 16 | +Append lines to the output instead of updating existing output, useful for status messages. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided. |
| 17 | + |
| 18 | +**webpack.config.js** |
| 19 | + |
| 20 | +```javascript |
| 21 | +module.exports = { |
| 22 | + //... |
| 23 | + infrastructureLogging: { |
| 24 | + appendOnly: true, |
| 25 | + level: 'verbose', |
| 26 | + }, |
| 27 | + plugins: [ |
| 28 | + (compiler) => { |
| 29 | + const logger = compiler.getInfrastructureLogger('MyPlugin'); |
| 30 | + logger.status('first output'); // this line won't be overridden with `appendOnly` enabled |
| 31 | + logger.status('second output'); |
| 32 | + }, |
| 33 | + ], |
| 34 | +}; |
| 35 | +``` |
| 36 | + |
| 37 | +## infrastructureLogging.colors |
| 38 | + |
| 39 | +<Badge text="5.31.0+" /> |
| 40 | + |
| 41 | +`boolean` |
| 42 | + |
| 43 | +Enable colorful output for infrastructure level logging. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided. |
| 44 | + |
| 45 | +**webpack.config.js** |
| 46 | + |
| 47 | +```javascript |
| 48 | +module.exports = { |
| 49 | + //... |
| 50 | + infrastructureLogging: { |
| 51 | + colors: true, |
| 52 | + level: 'verbose', |
| 53 | + }, |
| 54 | + plugins: [ |
| 55 | + (compiler) => { |
| 56 | + const logger = compiler.getInfrastructureLogger('MyPlugin'); |
| 57 | + logger.log('this output will be colorful'); |
| 58 | + }, |
| 59 | + ], |
| 60 | +}; |
| 61 | +``` |
| 62 | + |
| 63 | +## infrastructureLogging.console |
| 64 | + |
| 65 | +<Badge text="5.31.0+" /> |
| 66 | + |
| 67 | +`Console` |
| 68 | + |
| 69 | +Customize the console used for infrastructure level logging. |
| 70 | + |
| 71 | +**webpack.config.js** |
| 72 | + |
| 73 | +```javascript |
| 74 | +module.exports = { |
| 75 | + //... |
| 76 | + infrastructureLogging: { |
| 77 | + console: yourCustomConsole(), |
| 78 | + }, |
| 79 | +}; |
| 80 | +``` |
| 81 | + |
| 82 | +## infrastructureLogging.debug |
| 83 | + |
| 84 | +`string` `boolean = false` `RegExp` `function(name) => boolean` `[string, RegExp, function(name) => boolean]` |
| 85 | + |
| 86 | +Enable debug information of specified loggers such as plugins or loaders. Similar to [`stats.loggingDebug`](/configuration/stats/#statsloggingdebug) option but for infrastructure. Defaults to `false`. |
| 87 | + |
| 88 | +**webpack.config.js** |
| 89 | + |
| 90 | +```javascript |
| 91 | +module.exports = { |
| 92 | + //... |
| 93 | + infrastructureLogging: { |
| 94 | + level: 'info', |
| 95 | + debug: ['MyPlugin', /MyPlugin/, (name) => name.contains('MyPlugin')], |
| 96 | + }, |
| 97 | +}; |
| 98 | +``` |
| 99 | + |
| 100 | +## infrastructureLogging.level |
| 101 | + |
| 102 | +`string = 'info' : 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'` |
| 103 | + |
| 104 | +Enable infrastructure logging output. Similar to [`stats.logging`](/configuration/stats/#statslogging) option but for infrastructure. Defaults to `'info'`. |
| 105 | + |
| 106 | +Possible values: |
| 107 | + |
| 108 | +- `'none'` - disable logging |
| 109 | +- `'error'` - errors only |
| 110 | +- `'warn'` - errors and warnings only |
| 111 | +- `'info'` - errors, warnings, and info messages |
| 112 | +- `'log'` - errors, warnings, info messages, log messages, groups, clears. Collapsed groups are displayed in a collapsed state. |
| 113 | +- `'verbose'` - log everything except debug and trace. Collapsed groups are displayed in expanded state. |
| 114 | + |
| 115 | +**webpack.config.js** |
| 116 | + |
| 117 | +```javascript |
| 118 | +module.exports = { |
| 119 | + //... |
| 120 | + infrastructureLogging: { |
| 121 | + level: 'info', |
| 122 | + }, |
| 123 | +}; |
| 124 | +``` |
| 125 | + |
| 126 | +## infrastructureLogging.stream |
| 127 | + |
| 128 | +<Badge text="5.31.0+" /> |
| 129 | + |
| 130 | +`NodeJS.WritableStream = process.stderr` |
| 131 | + |
| 132 | +Stream used for logging output. Defaults to `process.stderr`. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided. |
| 133 | + |
| 134 | +**webpack.config.js** |
| 135 | + |
| 136 | +```javascript |
| 137 | +module.exports = { |
| 138 | + //... |
| 139 | + infrastructureLogging: { |
| 140 | + stream: process.stderr, |
| 141 | + }, |
| 142 | +}; |
| 143 | +``` |
| 144 | + |
| 145 | +T> In the case of a TTY stream, `colors` is enabled and `appendOnly` is disabled, and vice versa. |
0 commit comments