Author Topic: Which logging framework do you use?  (Read 3862 times)

Marcos Calleja

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Which logging framework do you use?
« on: July 28, 2015, 09:46:18 pm »
Hi!. I want to add a logging framework to my addin. I tried log4net and NLog but no one write in the files configurated.

I'm thinking that maybe it's happening for be encapsulated in the plugin, but i don't actually know.

So I came here to ask if someone has used one of these or another and work for him/her.

Greetings and thanks for your time.  :)

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: Which logging framework do you use?
« Reply #1 on: July 28, 2015, 10:16:29 pm »
Hi Marcos,

I used log4net in my prior company. It's quite good but not easy to configure.

If you don't have to log realy much you can do it yourself aswell:


Code: [Select]
public class SimpleLogger
    {
        public void Log(string str)
        {
            try
            {
                using (StreamWriter file = new StreamWriter("c:/../...", true))
                {
                    file.WriteLine(str);
                    // Close shouldn't be needed cause of using
                    //file.Close();
                }
            }
            catch (Exception e)
            {
                // Concider more logging
                throw;
            }          
        }
    }

Edit:
By the way: log4net runs under userprivileges, it might be, that no logging is working, because the user running ea got no access to the file you want to log to.
Other suggestion: Do you changed your filter? If you got log4net configurated as "OFF" anything will be logged.
« Last Edit: July 28, 2015, 10:28:40 pm by ericeckstein »

Marcos Calleja

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Which logging framework do you use?
« Reply #2 on: July 28, 2015, 10:30:41 pm »
Yes, after lose all the day trying different frameworks I was thinking about create my own logger with different levels, etc.

But when i started i thought, if it's done why are you gonna waste time doing something worst? xD.

Anyway I'm sure the configuration of log4net was right, because I tested it in another couple of simple C# projects. But when I put it to work in the EA add-in it didn't.

Did you configure or do something special to make it work with your EA add-ins?

Thanks a lot for you quickly answer.  :)

Edit: Yep, i'm logged with an administrator role so... it supposed to work. In the beginning i thought the file was in a strange location but i change the file location to be c:\log.txt and nothing.
And i tried with a lot of filters/configurations/everything.

Thanks for your help, but i think is better if i just create my own logger.
« Last Edit: July 28, 2015, 10:38:56 pm by mcalleja »

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: Which logging framework do you use?
« Reply #3 on: July 28, 2015, 10:48:55 pm »
Hi Marcos,

mh. Well it's quite long I used log4net, so I am not realy sure what I did - and I didn't used it with EA but MSCRM, so I can't tell for sure if it would work anyhow.

If you already tried this configurations I'm quite clueless myself now, sorry.

Maybe someone else will be able to help you out.

PS: Yes I know this is a kind of stupd question: But did you asure your addin is running at all? Did you debug to be sure log4net methods are called?

Regards,
Eric

Marcos Calleja

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Which logging framework do you use?
« Reply #4 on: July 28, 2015, 11:08:43 pm »
Hi! Yes it's working, I thought the same haha but... it's connecting with a database, using a REST service and everything work.

Actually the plugin is "almost done" and i'm adding the log now. Until now i could debug directly using Visual.

Anyway thanks for everything.