<commit_before>#include <QtQuick>

#include "person.h"
#include "company.h"

#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>

#include "ConsoleAppender"
#include "ColorConsoleAppender"
#include "SimpleTimeLayout"
#include "Logger"
#include "LogManager"

#include "SystemlogAppender"
#include "Level"
#include "DailyRollingFileAppender"
#include "PropertyConfigurator"
#include "helpers/factory.h"
#include "Appender"

#include <QFile>
#include "qmllogger.h"

Log4Qt::Appender *create_system_log_appender() {
    return new Log4Qt::SystemLogAppender;
}

/**
 * @brief initLogging
 * @param app Is used for determining app-specific config, log file locations, etc
 */
void initLogging(const QCoreApplication& app)
{
    Log4Qt::Factory::registerAppender("org.apache.log4j.SystemLogAppender", create_system_log_appender);

    const QString logConfigFilePath("/home/nemo/.config/harbour-log4qtdemo/log4qt.conf");
    const QString fallbackLogConfigPath("/usr/share/harbour-log4qtdemo/log4qt.conf");

    const QString& usedConfigFile = QFile::exists(logConfigFilePath) ? logConfigFilePath : fallbackLogConfigPath;
    Log4Qt::PropertyConfigurator::configure(usedConfigFile);
    Log4Qt::LogManager::setHandleQtMessages(true);

    qDebug() << "Using following log config file: " << usedConfigFile;


    /**
    // Normally you call it all from .conf properties, but you can instantiate it manually too
    Log4Qt::LogManager::rootLogger();

    // Note that it doesn't work for QML logs from device

    Log4Qt::SimpleTimeLayout *p_layout = new Log4Qt::SimpleTimeLayout();

    p_layout->setName(QLatin1String("root layout"));
    p_layout->activateOptions();

    // Create an appender
    Log4Qt::ColorConsoleAppender *p_consoleAppender = new Log4Qt::ColorConsoleAppender(p_layout, Log4Qt::ColorConsoleAppender::STDOUT_TARGET);
    p_consoleAppender->setName(QLatin1String("root console appender"));
    p_consoleAppender->activateOptions();

    Log4Qt::SystemLogAppender *p_syslogAppender = new Log4Qt::SystemLogAppender();
    p_syslogAppender->setServiceName("journalctl");
    p_syslogAppender->setName(QLatin1String("root sysylog appender"));
    p_syslogAppender->setLayout(p_layout);

    // Root logger gets all levels of logs, but let's send only
    // important ones to syslog
    p_syslogAppender->setThreshold(Log4Qt::Level(Log4Qt::Level::ERROR_INT));
<commit_msg>Use app name from CoreApplication<commit_after>#include <QtQuick>

#include "person.h"
#include "company.h"

#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>

#include "Logger"
#include "LogManager"

// Includes below are needed for manual configuration. If you use .conf file for configuring,
// just PropertyConfigurator is enough
//#include "ConsoleAppender"
//#include "ColorConsoleAppender"
//#include "SimpleTimeLayout"
//#include "SystemlogAppender"
//#include "Level"
//#include "DailyRollingFileAppender"
//#include "helpers/factory.h"
//#include "Appender"


#include "PropertyConfigurator"

#include <QFile>
#include "qmllogger.h"

//Log4Qt::Appender *create_system_log_appender() {
//    return new Log4Qt::SystemLogAppender;
//}

/**
 * @brief initLogging
 * @param app Is used for determining app-specific config, log file locations, etc
 */
void initLogging(const QCoreApplication& app)
{

    const QString& binaryName = QCoreApplication::applicationName();
    const QString logConfigFilePath("/home/nemo/.config/" + binaryName + "/log4qt.conf");
    const QString fallbackLogConfigPath("/usr/share/" + binaryName + "/log4qt.conf");

    const QString& usedConfigFile = QFile::exists(logConfigFilePath) ? logConfigFilePath : fallbackLogConfigPath;
    Log4Qt::PropertyConfigurator::configure(usedConfigFile);
    Log4Qt::LogManager::setHandleQtMessages(true);

    qDebug() << "Using following log config file: " << usedConfigFile;


    /**
    // Normally you call it all from .conf properties, but you can instantiate it manually too
    Log4Qt::Factory::registerAppender("org.apache.log4j.SystemLogAppender", create_system_log_appender);
    Log4Qt::LogManager::rootLogger();

    // Note that it doesn't work for QML logs from device

    Log4Qt::SimpleTimeLayout *p_layout = new Log4Qt::SimpleTimeLayout();

    p_layout->setName(QLatin1String("root layout"));
    p_layout->activateOptions();

    // Create an appender
    Log4Qt::ColorConsoleAppender *p_consoleAppender = new Log4Qt::ColorConsoleAppender(p_layout, Log4Qt::ColorConsoleAppender::STDOUT_TARGET);
    p_consoleAppender->setName(QLatin1String("root console appender"));
    p_consoleAppender->activateOptions();

    Log4Qt::SystemLogAppender *p_syslogAppender = new Log4Qt::SystemLogAppender();
    p_syslogAppender->setServiceName("journalctl");
    p_syslogAppender->setName(QLatin1String("root sysylog appender"));
    p_syslogAppender->setLayout(p_layout);

    // Root logger gets all levels of logs, but let's send only
    // important ones to syslog
    p_syslogAppender->setThreshold(Log4Qt::Level(Log4Qt::Level::ERROR_INT));

{'fraction_non_alphanumeric': 0.1196116504854369, 'fraction_numerical': 0.00854368932038835, 'mean_word_length': 5.672279792746114, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3778541', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1582, 'n_words': 346}