---
title: "2.14 std::clog"
description: "The `std::clog` object is the standard logging output stream in C++. It is intended for writing informational messages, debugging information, and program logs. Unlike `std::cerr`, which is typically reserved for error messages, `std::clog` is used for general logging purposes. The…"
url: "https://edcret.in/docs/cpp-programming/input-and-output-cplusplus/2-14-stdclog/"
updated: "2026-07-28"
category: C++ Programming / Input and Output
---

# 2.14 std::clog

The `std::clog` object is the standard logging output stream in C++. It is intended for writing informational messages, debugging information, and program logs. Unlike `std::cerr`, which is typically reserved for error messages, `std::clog` is used for general logging purposes.

The `std::clog` stream is buffered, meaning that output may be stored temporarily before being written to the output device. Buffering improves performance when writing large amounts of log data.

## Source Code

```
#include <iostream>

int main()
{
    std::cout << "Application started.\n";

    std::clog << "Log: Initializing resources.\n";
    std::clog << "Log: Loading configuration.\n";

    std::cout << "Application running.\n";

    return 0;
}
```

## Output

```
Application started.
Log: Initializing resources.
Log: Loading configuration.
Application running.
```

## Explanation

- `std::clog` is the standard logging output stream defined in the `<iostream>` library.
- It is commonly used to display diagnostic messages, debugging information, and application logs.
- Unlike `std::cerr`, `std::clog` is buffered, allowing multiple log messages to be grouped before they are written to the output device.
- Buffering generally improves output performance, especially when producing large amounts of logging information.
- The stream insertion operator (`<<`) is used with `std::clog` in the same way as with `std::cout` and `std::cerr`.
- Using `std::clog` helps separate logging information from normal program output and error messages.
- `return 0;` terminates the program successfully.
