> For the complete documentation index, see [llms.txt](https://docs.codemash.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codemash.io/api/logs.md).

# Logs & Monitoring

CodeMash **Logs** service logs all the requests and errors in your project. All the logs can be reached on the dashboard. In addition, you can create your custom logs from your own application.

To start using logs services and API methods you firstly need to enable logs service in your CodeMash dashboard.

Features included in logs service:

1. Logs - logs of various actions in your application.

## Using SDK

If you decide to use one of our provided SDK, the following code shows how to initialize logs service.

{% tabs %}
{% tab title=".NET" %}

```csharp
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";

var client = new CodeMashClient(apiKey, projectId);
var logsService = new CodeMashLogsService(client);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashLog;

class CodemashService
{
    protected CodemashLog $codemashLog;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashLog = new CodemashLog($client);
    }

    
}
```

{% endtab %}
{% endtabs %}

## Example

The following are examples of logs SDK using different languages and frameworks.

{% tabs %}
{% tab title=".NET" %}

```csharp
using System;
using CodeMash.Client;
using CodeMash.Membership.Services;
using Isidos.CodeMash.ServiceContracts;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1. Get your Project ID and Secret Key
            var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
            var apiKey = "{YOUR_SECRET_KEY}";

            // 2. Create a general client for API calls
            var client = new CodeMashClient(apiKey, projectId);
            
            // 3. Create a service object
            var logsService = new CodeMashLogsService(client);

            // 4. Call an API method
            logsService.CreateLog(new CreateLogRequest
            {
                Message = "Custom log",
                Level = "Information"
            });
        }
    }
}
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashLog;

class CodemashService
{
    protected CodemashLog $codemashLog;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashLog = new CodemashLog($client);
    }

    public function log() 
    {
        $responseData = $this->codemashLog->create([
            'message' => 'Custom log',
            'level' => 'Warning'
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

## Working with Logs Service

The following links explore the usage of logs service:

{% content-ref url="/pages/-LwUEOA\_mR3dstrNzr3A" %}
[Logs & Monitoring](/dashboard/logs.md)
{% endcontent-ref %}


---

# 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.codemash.io/api/logs.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.
