<!-- source: docs/api/2_capi/log/index.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log -->

# Logging

The logging service is only available in Cloud Code.  It allows you to log messages to your app's Error Logs which can be found
via the [Monitoring | Global Monitoring | Recent Errors](https://portal.braincloudservers.com/admin/dashboard#/monitoring/globallogs) page of the brainCloud portal.

 
### API Summary

### Log Messages

Standard info, warning, and error logging APIs:

* [LogInfo](/api/cc/log/loginfo) - Logs an info message with string-based context.
* [LogInfoJson](/api/cc/log/loginfojson) - Logs an info message with string-based context.
* [LogWarning](/api/cc/log/logwarning) - Logs an warning with string-based context.
* [LogWarningJson](/api/cc/log/logwarningjson) - Logs an warning with json context.
* [LogError](/api/cc/log/logerror) - Logs an error with string-based context.
* [LogErrorJson](/api/cc/log/logerrorjson) - Logs an error with json context.

> **Info:** As of Release 3.11 these methods have been added to the bridge for convenience.

### Debugging

brainCloud now supports debug-level log messages, which display only in the *activity pane* of the **Cloud Code Editor** and **API Explorers**. They are not written to the logging database.

The debug-level log APIs are only available from the [<code>bridge</code>](/api/cc/bridge).


---

<!-- source: docs/api/2_capi/log/logerror.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/logerror -->

# LogError

Logs an App Error message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_ERROR |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional string-format information to include with the message.

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test error message";
var context = "Test error context";
var logProxy = bridge.getLogServiceProxy();

logProxy.logError(errorMessage, context);

```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/2_capi/log/logerrorjson.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/logerrorjson -->

# LogErrorJson

Logs an App Error message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_ERROR |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional JSON-format information to include with the message.  

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test error message";
var context = { "example": "json" };
var logProxy = bridge.getLogServiceProxy();

logProxy.logErrorJson(errorMessage, context);

```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/2_capi/log/loginfo.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/loginfo -->

# LogInfo

Logs an App Info message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_INFO |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional string-format information to include with the message.

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test info message";
var context = "Test info context";
var logProxy = bridge.getLogServiceProxy();

logProxy.logInfo(errorMessage, context);

```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/2_capi/log/loginfojson.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/loginfojson -->

# LogInfoJson

Logs an App Info message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_INFO |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional JSON-format information to include with the message.  

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test info message";
var context = { "example": "json" };
var logProxy = bridge.getLogServiceProxy();

logProxy.logInfoJson(errorMessage, context);

```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/2_capi/log/logwarning.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/logwarning -->

# LogWarning

Logs an App Warning message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_WARNING |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional string-format information to include with the message.

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test warning message";
var context = "Test warning context";
var logProxy = bridge.getLogServiceProxy();

logProxy.logWarning(errorMessage, context)
```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/2_capi/log/logwarningjson.md -->
<!-- url: https://docs.braincloudservers.com/api/capi/log/logwarningjson -->

# LogWarningJson

Logs an App Warning message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_WARNING |

## Method Parameters
Parameter | Description
--------- | -----------
errorMessage | The error message.
context | Additional JSON-format information to include with the message.  

## Usage

**C#:**

```csharp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**C++:**

```cpp
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Obj-C:**

```objectivec
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Java:**

```java
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**JavaScript:**

```javascript
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Dart:**

```dart
// Cloud Code only. To view example, switch to the Cloud Code tab
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- Cloud Code only. To view example, switch to the Cloud Code tab
```

**Cloud Code:**

```cfscript
var errorMessage = "Test warning message";
var context = { "example": "json" };
var logProxy = bridge.getLogServiceProxy();

logProxy.logWarningJson(errorMessage, context)
```

**Raw:**

```r
// N/A
```

<details>
<summary>JSON Response</summary>

```json
{
    "status": 200,
    "data": null
}
```
</details>


---

<!-- source: docs/api/4_s2s/log/index.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log -->

# Logging

The logging service is only available in Cloud Code.  It allows you to log messages to your app's Exception Logs which can be found
on the [Global Monitoring - Recent Errors page](https://portal.braincloudservers.com/admin/dashboard#/monitoring/globallogs) of the brainCloud portal.

### API Summary

### Log

Standard info, warning, and error logging APIs:

* [LogInfo](/api/s2s/log/loginfo) - Logs an info message with string-based context.
* [LogInfoJson](/api/s2s/log/loginfojson) - Logs an info message with string-based context.
* [LogWarning](/api/s2s/log/logwarning) - Logs an warning with string-based context.
* [LogWarningJson](/api/s2s/log/logwarningjson) - Logs an warning with json context.
* [LogError](/api/s2s/log/logerror) - Logs an error with string-based context.
* [LogErrorJson](/api/s2s/log/logerrorjson) - Logs an error with json context.

> **Info:** As of Release 3.11 these methods have been added to the bridge for convenience.

### Debugging

brainCloud now supports debug-level log messages, which display only in the *activity pane* of the **Cloud Code Editor** and **API Explorers**. They are not written to the logging database.

The debug-level log APIs are only available from the [bridge](/api/cc/bridge).


---

<!-- source: docs/api/4_s2s/log/logerror.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/logerror -->

# LogError

Logs an App Error message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_ERROR |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| context      | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test error message";
var context = "Test error context";
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logError(errorMessage, context);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_ERROR",
    "data": {
        "errorMessage": "Test error message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/log/logerrorjson.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/logerrorjson -->

# LogErrorJson

Logs an App Error message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_ERROR |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| jsonContext  | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test error message";
var jsonContext = {
    "msg": "Test error context"
};
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logErrorJson(errorMessage, jsonContext);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_ERROR",
    "data": {
        "errorMessage": "Test error message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/log/loginfo.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/loginfo -->

# LogInfo

Logs an App Info message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_INFO |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| context      | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test info message";
var context = "Test info context";
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logInfo(errorMessage, context);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_INFO",
    "data": {
        "errorMessage": "Test info message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/log/loginfojson.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/loginfojson -->

# LogInfoJson

Logs an App Info message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_INFO |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| jsonContext  | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test info message";
var jsonContext = {
    "msg": "Test error context"
};
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logInfoJson(errorMessage, jsonContext);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_INFO",
    "data": {
        "errorMessage": "Test info message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/log/logwarning.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/logwarning -->

# LogWarning

Logs an App Warning message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_WARNING |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| context      | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test warning message";
var context = "Test warning context";
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logWarning(errorMessage, context);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_WARNING",
    "data": {
        "errorMessage": "Test warning message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/log/logwarningjson.md -->
<!-- url: https://docs.braincloudservers.com/api/s2s/log/logwarningjson -->

# LogWarningJson

Logs an App Warning message to the error log.

| Service | Operation |
| ------- | --------- |
| log | LOG_WARNING |

## Method Parameters

| Parameter    | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| errorMessage | The error message.                                                  |
| jsonContext  | JSON formatted string that will display via the context icon click. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var errorMessage = "Test warning message";
var jsonContext = {
    "msg": "Test error context"
};
var logProxy = bridge.getLogServiceProxy();

var postResult = logProxy.logWarningJson(errorMessage, jsonContext);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "log",
    "operation": "LOG_WARNING",
    "data": {
        "errorMessage": "Test warning message",
        "jsonContext": {
            "msg": "Test error context"
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": null,
    "status": 200
}
```

</details>
