Closed dsiconnelli closed 6 years ago
There is a Windows Form example app
Have you tried this example
https://github.com/jjchiw/gelf4net/tree/master/examples/RandomSentence
just change the App.config
and check if it works.....
The only difference that I see between your code is that you configure log4net
everytime the event
btnError_Click(object sender, EventArgs e)
is fired, try to configure log4net
in the ctr
public Form1()
{
InitializeComponent();
log4net.Config.XmlConfigurator.Configure();
}
private void btnError_Click(object sender, EventArgs e)
{
log.Debug(txtMessage.Text);
}
And if you can paste your App.config
to see the configuration of log4net
Oh sorry. Thanks. What I have now (based on the example) is this. Starting the App or clicking buttons does nothing. I changed a bit the config and it's a copy paste now minus the Graylog2 Url.
public partial class Form1 : Form
{
protected static readonly ILog log = LogManager.GetLogger(typeof(Form1));
public Form1()
{
InitializeComponent();
log4net.Config.XmlConfigurator.Configure();
}
private void Form1_Load(object sender, EventArgs e)
{
log.Debug("Starting the Application IA.SendTrace");
LogSomething();
}
private void LogSomething()
{
log.Debug(String.Format("Application IA.SendTrace: {0}", txtMessage.Text));
}
private void btnMessage_Click(object sender, EventArgs e)
{
log.Debug(String.Format("Application IA.SendTrace: {0}", txtMessage.Text));
}
Ok. I figured out what was the difference but I'm not shure why. Both apps are now working with my local Graylog2
In the consoles app, I have the nuget packages log4net 2.0.8 and Gelf4Net.HttpAppender 1.0.0.11
In the WinForms app I have log4net 2.0.8 and Gelf4Net 3.0.0.7.
What I had in the WinForms app were the same Nuget packages installed as the console app (log4net with Gelf4Net.HttpAppender 1.0.0.11) and that didn't work.
Not shure why as I thought that I only needed Gelf4Net.HttpAppender and that Gelf4Net had all the other appenders I don't need.
Not shure why as I thought that I only needed Gelf4Net.HttpAppender and that Gelf4Net had all the other appenders I don't need.
Technically that was the objective of creating the "standalone-packages" I'm not sure why it's not working in a WinForms App.... I'll create some samples with "standalone-packages" in a WinForm App....
Great that everything is working in local, now let's hope that when targeting to Azure everything works fine :)
I'll close this issue and create a new one that will be focused in create samples
I looked at the code of the SimpleConsoleApplicationHttpPackage console app. Pretty simple and it works with a local (in virtual box) Graylog2 VM (for now). However I tried the three lines of code which seem to matter and no message is sent.
The configs are the same. My code is as follow.
UPDATE: Now I have the simplest code I can, still nothing is sent :-(. It's almost a copy paste from the example project.