Integration instructions for popular languages and frameworks


Create new project in Muscula App by pressing button "Add new project"

Provide any name you like.

Create log

Every project can have many logs. Just like your website can contain frontend logger and backend logger.


Paste integration code

Paste it on your website after <head>. Replace LOG_ID with your current LOG ID. If you place code directly from Muscula Application LOG ID will be filled.

<script type="text/javascript">
    window.Muscula = {
        settings: {
            logId: LOG_ID,
            suppressErrors: false,
    (function () {
        var m = document.createElement('script');
        m.type = 'text/javascript';
        m.async = true;
        m.src = '';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(m, s); = function () {
            var a;
   = function () {};
        window.Muscula.errors = [];
        window.onerror = function () {
            return window.Muscula.settings.suppressErrors === undefined;

You can also log own errors with website script using Muscula.log functions:

Muscula.log.fatal(msg, info, ex)
Muscula.log.error(msg, info, ex)
Muscula.log.warning(msg, info, ex), info, ex)
Muscula.log.debug(msg, info, ex)

Just make sure Muscula was loaded and functions exists before using them.

JavaScript / TypeScript application

Install Muscula appender by running command from your application directory:

npm install --save

Initializde Muscula in index.js / index.ts of your Application

import * as MusculaLog from 'muscula-webapp-js-logger'; Muscula.Init(LOG_ID); // logId will be filled when You will be copying instructions from Muscula App, after creating new log

Import Muscula Logger when you need to use it

import * as MusculaLog from 'muscula-webapp-js-logger';

Use it like:

try { / /your code } catch(excetpion) { Muscula.Error('My error occurred', exception); }

You can also use other methods for logging

Muscula.Fatal(message: string, exception?: Error, info?: any);
Muscula.Error(message: string, exception?: Error, info?: any);
Muscula.Info(message: string, info?: any);
Muscula.Warning(message: string, info?: any);
Muscula.Debug(message: string, info?: any);
Muscula.Trace(message: string, info?: any);

Info object

You can pass own data into Muscula system as "info" object for example:
try { / /your code } catch(excetpion) { Muscula.Error('My error occurred', exception, {userId: 'user1', 'basketAmount': 0}); }


Install Muscula appender by running command from your application directory:

composer require muscula/muscula-php-logger

Initialise Muscula in index.php of your Application

$handler = MusculaHandler::getInstance(); $handler->start(LOG_ID);

From this moment all your errors will be visible in muscula system.
At can find full documentation

C# ((Microsoft Extensions Logging, .NET + .NET Core)

Install nuget package


Initialize logger at Program.cs

public static IHostBuilder CreateHostBuilder(string[] args) =>
        .ConfigureLogging(logging =>
                settingsBuilder =>
                    return settingsBuilder.Build();
        .ConfigureWebHostDefaults(webBuilder =>

C# ((Log4Net, .NET + .NET Core)

Install nuget package


Provide log4net.config file

<?xml version="1.0" encoding="utf-8" ?>
    <appender name="MusculaAppender" 
    type="Muscula.Csharp.Extensions.Logging.Log4Net.MusculaAppender, Muscula.Csharp.Extensions.Logging.Log4Net" >
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
            <LogId value="LOG_ID" />
        <level value="ALL" />
        <appender-ref ref="MusculaAppender" />

Initialize logger at Startup.cs

services.AddLogging(b => b.AddLog4Net("log4net.config"));

Java (log4j)

Add dependency to pom file


Configure log4j in file src/main/resources/log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
        <MusculaAppender name="MusculaAppender" logId="LOG_ID"/>
        <Root level="error">
            <AppenderRef ref="MusculaAppender"/>

Check out our demo project

Java (logback)

Add dependency to pom file


Configure logback in file src/main/resources/logback.xml

    <appender name="muscula" class="com.muscula.logback.appender.MusculaAppender">
    <root level="info">
        <appender-ref ref="muscula"/>


Use it like any other logger

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);
    public static void main(String[] args) {
        for(int i=0; i<10; i++)
        logger.error("test", new RuntimeException("logback error test"));

Check out our demo project