You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Wim Sturkenboom <Wi...@hambisana.com> on 2014/11/21 12:29:35 UTC

Multiple applications to a log4net remoting server

Hello all

Let me start saying that I know about nothing about log4net (even after trying to read documentation and trying to understand examples). So please forgive any incorrect wording. Based on examples, I've managed to let an application write to a remotingserver (sending to / listening on port 8085) and the remotingserver writes it nicely to a file.

I have modified the remotingserver example to a (windows) service and that also works fine.

Now I'm in need of this one remotingserver application to handle logs from different applications to different logfiles. The application side of things is not an issue, I think; just use another port.

But how do I write an application that contains multiple 'remotingservers' or one 'remotingserver' listening on different ports? Any pointers are at this stage appreciated. A thread for each port that I want to listen on? If so, how do I 'tell the thread' to use a specific configuration? Or something else.

Current code for remotingserver (in a windows service)

        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.

            System.Diagnostics.EventLog.WriteEntry(String.Format("dsrp_log4net_service", version.getVersion()),
                                          ServiceName + "starting");

            // Log an info level message
            if (log.IsInfoEnabled) log.Info(String.Format("dsrp_log4net_service v{0} started", version.getVersion()));

            // Configure remoting. This loads the TCP channel as specified in the .config file.
            RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);

            // Publish the remote logging server. This is done using the log4net plugin.
            log4net.LogManager.GetRepository().PluginMap.Add(new log4net.Plugin.RemoteLoggingServerPlugin("LoggingSink"));

            System.Diagnostics.EventLog.WriteEntry(String.Format("dsrp_log4net_service", version.getVersion()),
                                          ServiceName + "started");

        }


Thanks in advance for any help. WimS

RE: Multiple applications to a log4net remoting server

Posted by Wim Sturkenboom <Wi...@hambisana.com>.
Thanks for the reply.

From the description, I’d say no; it does what my current version does. It writes everything into a single log file; I find that a little messy. I’m in need of something that can keep the logs separate per application.

WimS

From: Svante Seleborg [mailto:software@axantum.com]
Sent: Friday, November 21, 2014 2:09 PM
To: Log4NET User
Subject: Re: Multiple applications to a log4net remoting server

Hello,

Check out if the following meets your needs: https://log4netremotelogging.codeplex.com/ .

Best regards,

Svante

On Fri, Nov 21, 2014 at 12:29 PM, Wim Sturkenboom <Wi...@hambisana.com>> wrote:
Hello all

Let me start saying that I know about nothing about log4net (even after trying to read documentation and trying to understand examples). So please forgive any incorrect wording. Based on examples, I’ve managed to let an application write to a remotingserver (sending to / listening on port 8085) and the remotingserver writes it nicely to a file.

I have modified the remotingserver example to a (windows) service and that also works fine.

Now I’m in need of this one remotingserver application to handle logs from different applications to different logfiles. The application side of things is not an issue, I think; just use another port.

But how do I write an application that contains multiple ‘remotingservers’ or one ‘remotingserver’ listening on different ports? Any pointers are at this stage appreciated. A thread for each port that I want to listen on? If so, how do I ‘tell the thread’ to use a specific configuration? Or something else.

Current code for remotingserver (in a windows service)

        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.

            System.Diagnostics.EventLog.WriteEntry(String.Format("dsrp_log4net_service", version.getVersion()),
                                          ServiceName + "starting");

            // Log an info level message
            if (log.IsInfoEnabled) log.Info(String.Format("dsrp_log4net_service v{0} started", version.getVersion()));

            // Configure remoting. This loads the TCP channel as specified in the .config file.
            RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);

            // Publish the remote logging server. This is done using the log4net plugin.
            log4net.LogManager.GetRepository().PluginMap.Add(new log4net.Plugin.RemoteLoggingServerPlugin("LoggingSink"));

            System.Diagnostics.EventLog.WriteEntry(String.Format("dsrp_log4net_service", version.getVersion()),
                                          ServiceName + "started");

        }


Thanks in advance for any help. WimS


Re: Multiple applications to a log4net remoting server

Posted by Svante Seleborg <so...@axantum.com>.
Hello,

Check out if the following meets your needs:
https://log4netremotelogging.codeplex.com/ .

Best regards,

Svante

On Fri, Nov 21, 2014 at 12:29 PM, Wim Sturkenboom <
Wim.Sturkenboom@hambisana.com> wrote:

>  Hello all
>
>
>
> Let me start saying that I know about nothing about log4net (even after
> trying to read documentation and trying to understand examples). So please
> forgive any incorrect wording. Based on examples, I’ve managed to let an
> application write to a remotingserver (sending to / listening on port 8085)
> and the remotingserver writes it nicely to a file.
>
>
>
> I have modified the remotingserver example to a (windows) service and that
> also works fine.
>
>
>
> Now I’m in need of this one remotingserver application to handle logs from
> different applications to different logfiles. The application side of
> things is not an issue, I think; just use another port.
>
>
>
> But how do I write an application that contains multiple ‘remotingservers’
> or one ‘remotingserver’ listening on different ports? Any pointers are at
> this stage appreciated. A thread for each port that I want to listen on? If
> so, how do I ‘tell the thread’ to use a specific configuration? Or
> something else.
>
>
>
> Current code for remotingserver (in a windows service)
>
>
>
>         protected override void OnStart(string[] args)
>
>         {
>
>             // TODO: Add code here to start your service.
>
>
>
>             System.Diagnostics.EventLog.WriteEntry(String.Format(
> "dsrp_log4net_service", version.getVersion()),
>
>                                           ServiceName + "starting");
>
>
>
>             // Log an info level message
>
>             if (log.IsInfoEnabled) log.Info(String.Format("dsrp_log4net_service
> v{0} started", version.getVersion()));
>
>
>
>             // Configure remoting. This loads the TCP channel as
> specified in the .config file.
>
>             RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
> false);
>
>
>
>             // Publish the remote logging server. This is done using the
> log4net plugin.
>
>             log4net.LogManager.GetRepository().PluginMap.Add(new
> log4net.Plugin.RemoteLoggingServerPlugin("LoggingSink"));
>
>
>
>             System.Diagnostics.EventLog.WriteEntry(String.Format(
> "dsrp_log4net_service", version.getVersion()),
>
>                                           ServiceName + "started");
>
>
>
>         }
>
>
>
>
>
> Thanks in advance for any help. WimS
>