<p>You can do this in your plugin:</p>

<pre><code>ExamplePlugin::log('the is the log message');
</code></pre>

<p>the log method has the following signature:</p>

<pre><code>log($msg, $level = LogLevel::Info, $force = false)
</code></pre>

<p>documentation <a href="https://docs.craftcms.com/api/v2/craft-baseplugin.html#public-properties" rel="nofollow noreferrer">is here</a></p>

<p>your log will appear in the app/storage/runtime/logs/pluginname.log</p>

CC BY-SA 3.0
2014-10-03T12:05:03.087Z
Do i have to create any class for this to work?
mbalparda
CC BY-SA 3.0
2014-10-03T12:07:02.030Z
if you have a custom plugin your will already have a main plugin class in the root of your plugin folder like ExamplePlugin.php this class will extend BasePlugin and thus get the static log function
Luke Holder
CC BY-SA 4.0
2014-10-03T12:01:58.670Z
2018-09-20T21:24:44.713Z
2018-09-20T21:24:44.713Z
Luke Holder
<p>Is there any way to create a custom log in Craft? I need to log some actions inside a controller/service in a custom plugin.</p>

<plugin-development>
Custom Log in Craft
# Custom Log in Craft

(Asked by: username_0 on 2014-10-03)

Is there any way to create a custom log in Craft? I need to log some actions inside a controller/service in a custom plugin.

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2014-10-03. Score: 14 | Accepted answer

You can do this in your plugin:
ExamplePlugin::log('the is the log message');

the log method has the following signature:
log($msg, $level = LogLevel::Info, $force = false)

documentation is here
your log will appear in the app/storage/runtime/logs/pluginname.log

> **Comments:**
> **username_0**: Do i have to create any class for this to work?  
> **username_1**: if you have a custom plugin your will already have a main plugin class in the root of your plugin folder like ExamplePlugin.php this class will extend BasePlugin and thus get the static log function  

---

