> For the complete documentation index, see [llms.txt](https://docs.buildings.ability.abb/collection/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.buildings.ability.abb/collection/german-14.2-freezed/dokumentation/engineering/skript-engine/python-skripte-schreiben/output-logging-und-fehlerbehandlung.md).

# Output Logging und Fehlerbehandlung

## Überblick

Beim Ausführen von Skripten im Eliona-System werden alle Ausgaben, wie beispielsweise `print`-Statements, Informationen über die Ausführung und Fehler, im **Grafana-Container (SSR)** protokolliert. Jede Skriptausführung erhält eine eindeutige **Function ID**, die es ermöglicht, die Ausgaben einzelner Skripte gezielt zu verfolgen. In dieser Anleitung wird erläutert, wie solche Log-Einträge aussehen können und was sie bedeuten.

## Wichtige Hinweise

### Sofortige Ausgabe mit `print`-Statements

Um sicherzustellen, dass `print`-Ausgaben sofort sichtbar sind, verwenden Sie in Ihren `print`-Statements den Parameter **`flush=True`**. Dies verhindert, dass die Ausgabe im Puffer bleibt und stellt sicher, dass sie direkt im Log erscheint.

**Beispiel:**

```python
print("Ergebnis: 42", flush=True)
```

### Fehlerprotokollierung

Alle Fehler, die während der Ausführung eines Skripts auftreten, werden ebenfalls im Grafana-Log angezeigt. Durch eine geeignete Fehlerbehandlung können Sie sicherstellen, dass zusätzliche Details protokolliert werden, was die Fehlersuche erleichtert.

**Beispiel für Fehlerprotokollierung:**

```python
try:
    # Code, der Fehler verursachen könnte
except Exception as e:
    print(f"Fehler aufgetreten: {e}", flush=True)
    raise
```

Durch die Verwendung von `flush=True` in Kombination mit einer umfassenden Fehlerbehandlung können Sie sicherstellen, dass alle wichtigen Informationen sofort im Log sichtbar sind und potenzielle Probleme schnell identifiziert und behoben werden können.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.buildings.ability.abb/collection/german-14.2-freezed/dokumentation/engineering/skript-engine/python-skripte-schreiben/output-logging-und-fehlerbehandlung.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
