Code Monkey home page Code Monkey logo

Comments (1)

danammeansbear avatar danammeansbear commented on August 27, 2024

Before using Log4Stash in your personal project, you want to create a console program to test your server with assuming everything works in postman. Tho postman could just be using curl....

but below should allow you to test if your system is working. you will need to modify your config correct. if you can log files to a local folder without issues then it might be a network issue.

`
using System;
using log4net;
using log4net.Config;
using System.IO;
using System.Reflection;

[assembly: XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

namespace ELKTest
{
internal class Program
{
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    static void Main(string[] args)
    {
        // Enable log4net internal debugging
        log4net.Util.LogLog.InternalDebugging = true;
        log4net.Config.XmlConfigurator.Configure();

        var logger = LogManager.GetLogger("elk_test");

        try
        {
            // Ensure log4net is configured
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
            //XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
            //log4net.Config.XmlConfigurator.Configure();

            //var logger = LogManager.GetLogger("console_test_logger");
            logger.Debug("This is a DEBUG message.");
            logger.Info("This is an INFO message.");
            logger.Warn("This is a WARN message.");
            logger.Error("This is an ERROR message.");

            Console.WriteLine("Log messages have been sent to Elasticsearch.");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error occurred: " + ex.Message);
        }
    }
}

}

`

from log4stash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.