---
title: LitLogger
description: >-
  Logger that enables remote experiment tracking, logging, and artifact
  management on lightning.ai.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/reference/generated/lightning.pytorch.loggers.LitLogger
---
# LitLogger {#litlogger}

### `class lightning.pytorch.loggers.LitLogger(root_dir=None, name=None, teamspace=None, metadata=None, store_step=True, log_model=False, save_logs=True, checkpoint_name=None)` {#lightning.pytorch.loggers.LitLogger}

Bases: [`Logger`](/docs/fabric/stable/api/generated/lightning.fabric.loggers.Logger#lightning.fabric.loggers.Logger "(in lightning v2.7.0.dev)")

Logger that enables remote experiment tracking, logging, and artifact management on lightning.ai.

Initialize the LightningLogger.

Parameters:

*   **root\_dir** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Folder where logs and metadata are stored (default: ./lightning\_logs).
    
*   **name** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Name of your experiment (defaults to a generated name).
    
*   **teamspace** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Teamspace name where charts and artifacts will appear.
    
*   **metadata** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]\]) – Extra metadata to associate with the experiment as tags.
    
*   **log\_model** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – If True, automatically log model checkpoints as artifacts.
    
*   **save\_logs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – If True, capture and upload terminal logs.
    
*   **checkpoint\_name** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Override the base name for logged checkpoints.
    

Example:

```python
from lightning.pytorch import Trainer
from lightning.pytorch.demos.boring_classes import BoringModel, BoringDataModule
from lightning.pytorch.loggers.litlogger import LitLogger

class LoggingModel(BoringModel):
    def training_step(self, batch, batch_idx: int):
        loss = self.step(batch)
        # logging the computed loss
        self.log("train_loss", loss)
        return {"loss": loss}

trainer = Trainer(
    max_epochs=10,
    enable_model_summary=False,
    logger=LitLogger("./lightning_logs", name="boring_model")
)
model = BoringModel()
data_module = BoringDataModule()
trainer.fit(model, data_module)
trainer.test(model, data_module)
```

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

Called after a checkpoint is saved.

Logs checkpoints as artifacts if enabled.

Return type:

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

#### `finalize(status=None)` {#lightning.pytorch.loggers.LitLogger.finalize}

Do any processing that is necessary to finalize an experiment.

Parameters:

**status** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Status that the experiment finished with (e.g. success, failed, aborted)

Return type:

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

#### `get_file(path, verbose=True)` {#lightning.pytorch.loggers.LitLogger.get_file}

Download a file artifact from the cloud for this experiment.

Parameters:

*   **path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Path where the file should be saved locally.
    
*   **verbose** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to print a confirmation message after download. Defaults to True.
    

Returns:

The local path where the file was saved.

Return type:

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

#### `log_file(path)` {#lightning.pytorch.loggers.LitLogger.log_file}

Log a file as an artifact to the Lightning platform.

The file will be logged in the Teamspace drive, under a folder identified by the experiment name.

Parameters:

**path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Path to the file to log.

Return type:

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

Example::

logger = LitLogger(…) logger.log\_file(‘config.yaml’)

#### `log_graph(model, input_array=None)` {#lightning.pytorch.loggers.LitLogger.log_graph}

Record model graph.

Parameters:

*   **model** ([`Module`](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module "(in PyTorch v2.15)")) – the model with an implementation of `forward`.
    
*   **input\_array** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\]) – input passes to model.forward
    

Return type:

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

#### `log_hyperparams(params, metrics=None)` {#lightning.pytorch.loggers.LitLogger.log_hyperparams}

Log hyperparams.

Return type:

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

#### `log_metadata(params)` {#lightning.pytorch.loggers.LitLogger.log_metadata}

Log hyperparams.

Return type:

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

#### `log_metrics(metrics, step=None)` {#lightning.pytorch.loggers.LitLogger.log_metrics}

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

Parameters:

*   **metrics** ([`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]) – Dictionary with metric names as keys and measured quantities as values
    
*   **step** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – 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)")

#### `log_model(model, staging_dir=None, verbose=False, version=None, metadata=None)` {#lightning.pytorch.loggers.LitLogger.log_model}

Save and upload a model object to cloud storage.

Parameters:

*   **model** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – The model object to save and upload (e.g., torch.nn.Module).
    
*   **staging\_dir** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Optional local directory for staging the model before upload.
    
*   **verbose** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to show progress bar during upload.
    
*   **version** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Optional version string for the model.
    
*   **metadata** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")\]\]) – Optional metadata dictionary to store with the model.
    

Return type:

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

#### `log_model_artifact(path, verbose=False, version=None)` {#lightning.pytorch.loggers.LitLogger.log_model_artifact}

Upload a model file or directory to cloud storage using litmodels.

Parameters:

*   **path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Path to the local model file or directory to upload.
    
*   **verbose** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to show progress bar during upload. Defaults to False.
    
*   **version** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Optional version string for the model. Defaults to the experiment version.
    

Return type:

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

#### `save()` {#lightning.pytorch.loggers.LitLogger.save}

Save log data.

Return type:

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

#### `property experiment: Optional[litlogger.Experiment]` {#lightning.pytorch.loggers.LitLogger.experiment}

Returns the underlying litlogger Experiment object.

#### `property log_dir: str` {#lightning.pytorch.loggers.LitLogger.log_dir}

The directory for this run’s tensorboard checkpoint.

By default, it is named `'version_${self.version}'` but it can be overridden by passing a string value for the constructor’s version parameter instead of `None` or an int.

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

Gets the name of the experiment.

#### `property root_dir: str` {#lightning.pytorch.loggers.LitLogger.root_dir}

Gets the save directory where the litlogger experiments are saved.

#### `property sub_dir: Optional[str]` {#lightning.pytorch.loggers.LitLogger.sub_dir}

Gets the sub directory where the TensorBoard experiments are saved.

#### `property version: Optional[str]` {#lightning.pytorch.loggers.LitLogger.version}

Get the experiment version - its time of creation.

---

**Navigation**

- Parent: [Generated](/docs/pytorch/2.6.6/reference/generated.md)
