---
title: logger
description: Dummy logger for internal use.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.loggers.logger
---
# logger {#logger}

Functions

- [`merge_dicts`](#lightning.pytorch.loggers.logger.merge_dicts) — Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function.

Classes

- [`DummyLogger`](#lightning.pytorch.loggers.logger.DummyLogger) — Dummy logger for internal use.
- [`Logger`](#lightning.pytorch.loggers.logger.Logger) — Base class for experiment loggers.

Abstract base class used to build new loggers.

### `class lightning.pytorch.loggers.logger.DummyLogger` {#lightning.pytorch.loggers.logger.DummyLogger}

Bases: [`Logger`](#lightning.pytorch.loggers.logger.Logger "lightning.pytorch.loggers.logger.Logger")

Dummy logger for internal use.

It is useful if we want to disable user’s logger for a feature, but still ensure that user code can run

#### `log_hyperparams(*args, **kwargs)` {#lightning.pytorch.loggers.logger.DummyLogger.log_hyperparams}

Record hyperparameters.

Parameters:

*   **params** – [`Namespace`](https://docs.python.org/3/library/argparse.html#argparse.Namespace "(in Python v3.15)") or Dict containing the hyperparameters
    
*   **args** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Optional positional arguments, depends on the specific logger being used
    
*   **kwargs** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Optional keyword arguments, depends on the specific logger being used
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `log_metrics(*args, **kwargs)` {#lightning.pytorch.loggers.logger.DummyLogger.log_metrics}

Records metrics. This method logs metrics as soon as it received them.

Parameters:

*   **metrics** – Dictionary with metric names as keys and measured quantities as values
    
*   **step** – Step number at which the metrics should be recorded
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `property experiment: _DummyExperiment` {#lightning.pytorch.loggers.logger.DummyLogger.experiment}

Return the experiment object associated with this logger.

#### `property name: str` {#lightning.pytorch.loggers.logger.DummyLogger.name}

Return the experiment name.

#### `property version: str` {#lightning.pytorch.loggers.logger.DummyLogger.version}

Return the experiment version.

### `class lightning.pytorch.loggers.logger.Logger` {#lightning.pytorch.loggers.logger.Logger}

Bases: [`Logger`](/docs/fabric/stable/api/generated/lightning.fabric.loggers.Logger#lightning.fabric.loggers.Logger "(in lightning v2.7.0.dev)"), [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.15)")

Base class for experiment loggers.

#### `after_save_checkpoint(checkpoint_callback)` {#lightning.pytorch.loggers.logger.Logger.after_save_checkpoint}

Called after model checkpoint callback saves a new checkpoint.

Parameters:

**checkpoint\_callback** ([`ModelCheckpoint`](/docs/pytorch/2.5.5/optional-api/api/lightning.pytorch.callbacks.ModelCheckpoint.md#lightning.pytorch.callbacks.ModelCheckpoint "lightning.pytorch.callbacks.model_checkpoint.ModelCheckpoint")) – the model checkpoint callback instance

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `property save_dir: Optional[str]` {#lightning.pytorch.loggers.logger.Logger.save_dir}

Return the root directory where experiment logs get saved, or None if the logger does not save data locally.

### `lightning.pytorch.loggers.logger.merge_dicts(dicts, agg_key_funcs=None, default_func=<function mean>)` {#lightning.pytorch.loggers.logger.merge_dicts}

Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function.

Parameters:

*   **dicts** ([`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")\[[`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "(in Python v3.15)")\]) – Sequence of dictionaries to be merged.
    
*   **agg\_key\_funcs** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "(in Python v3.15)")\]) – Mapping from key name to function. This function will aggregate a list of values, obtained from the same key of all dictionaries. If some key has no specified aggregation function, the default one will be used. Default is: `None` (all keys will be aggregated by the default function).
    
*   **default\_func** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable "(in Python v3.15)")\[\[[`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")\[[`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]\], [`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]) – Default function to aggregate keys, which are not presented in the agg\_key\_funcs map.
    

Return type:

[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")

Returns:

Dictionary with merged values.

Examples

```python
>>> import pprint
>>> d1 = {'a': 1.7, 'b': 2.0, 'c': 1, 'd': {'d1': 1, 'd3': 3}}
>>> d2 = {'a': 1.1, 'b': 2.2, 'v': 1, 'd': {'d1': 2, 'd2': 3}}
>>> d3 = {'a': 1.1, 'v': 2.3, 'd': {'d3': 3, 'd4': {'d5': 1}}}
>>> dflt_func = min
>>> agg_funcs = {'a': statistics.mean, 'v': max, 'd': {'d1': sum}}
>>> pprint.pprint(merge_dicts([d1, d2, d3], agg_funcs, dflt_func))
{'a': 1.3,
 'b': 2.0,
 'c': 1,
 'd': {'d1': 3, 'd2': 3, 'd3': 3, 'd4': {'d5': 1}},
 'v': 2.3}
```

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.5.5/optional-api/api.md)
