Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Log file advice?

Log file advice?

Scheduled Pinned Locked Moved C#
csharpwpfhelpquestioncode-review
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    geomeo123
    wrote on last edited by
    #1

    I'm writing a program that allows users to send commands to various serial devices. Most of the commands are "Button" orientated. By that I mean they press a button and everything is done for them; however I have a textbox that allows them to type in manual commands should there be something I don't have a button for that they really want to happen. I'm thinking about logging what commands they are typing in order to improve my program so that I can add other buttons that will help make life easier all. I'm wondering if there's a way to do that possibly on Github so that I can retrieve basically over web. Or if there's a better way to do it? I'm currently working in Csharp/WPF. I'm also thinking about logging some try/catch handler errors, so that I can analyze software bugs too, but I'm not too bothered about that right now.

    J L 2 Replies Last reply
    0
    • G geomeo123

      I'm writing a program that allows users to send commands to various serial devices. Most of the commands are "Button" orientated. By that I mean they press a button and everything is done for them; however I have a textbox that allows them to type in manual commands should there be something I don't have a button for that they really want to happen. I'm thinking about logging what commands they are typing in order to improve my program so that I can add other buttons that will help make life easier all. I'm wondering if there's a way to do that possibly on Github so that I can retrieve basically over web. Or if there's a better way to do it? I'm currently working in Csharp/WPF. I'm also thinking about logging some try/catch handler errors, so that I can analyze software bugs too, but I'm not too bothered about that right now.

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      First of course be aware of your user base. You are collecting information about them by doing that and there might be customer relation problems with that. And legal ones as well. Other than that all your are doing is collecting data remotely from an application. There are many ways to do that.

      geomeo123 wrote:

      if there's a way to do that possibly on Github

      As in that there is a library for that? Or that you want the data stored on Github? For the first I am certain there is. As for the second that wouldn't be my choice.

      geomeo123 wrote:

      thinking about logging some try/catch handler errors

      You should create a code API that logs the following - location. File/method. - Text that describes what it is - Additional information. This would be where you put exceptions, including stack traces. Then you call that where ever you want. There are specific libraries that provide 'logging'. In C# I have used log4net and Nlog. That provides the API that I mentioned ready to go. It does not however provide the 'destination'. I know you can find addins to log to databases. I suspect others. Another problem you will have is that since your application is remoting pushing data then someone might do something malicious to abuse your system. Basically you need to figure they will attempt this. So at a minimum you need to provide credentials. Although that probably is not enough. You might want to throttle as well so if they hack your app they can't just start blasting away. There are services that provide APIs that collect data also.

      Richard Andrew x64R 1 Reply Last reply
      0
      • J jschell

        First of course be aware of your user base. You are collecting information about them by doing that and there might be customer relation problems with that. And legal ones as well. Other than that all your are doing is collecting data remotely from an application. There are many ways to do that.

        geomeo123 wrote:

        if there's a way to do that possibly on Github

        As in that there is a library for that? Or that you want the data stored on Github? For the first I am certain there is. As for the second that wouldn't be my choice.

        geomeo123 wrote:

        thinking about logging some try/catch handler errors

        You should create a code API that logs the following - location. File/method. - Text that describes what it is - Additional information. This would be where you put exceptions, including stack traces. Then you call that where ever you want. There are specific libraries that provide 'logging'. In C# I have used log4net and Nlog. That provides the API that I mentioned ready to go. It does not however provide the 'destination'. I know you can find addins to log to databases. I suspect others. Another problem you will have is that since your application is remoting pushing data then someone might do something malicious to abuse your system. Basically you need to figure they will attempt this. So at a minimum you need to provide credentials. Although that probably is not enough. You might want to throttle as well so if they hack your app they can't just start blasting away. There are services that provide APIs that collect data also.

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        jschell wrote:

        There are many ways to do that

        If I may, but you didn't mention what any of them are. I too have been asking myself this question and I'm very interested to know what other people think.

        The difficult we do right away... ...the impossible takes slightly longer.

        G J 2 Replies Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          jschell wrote:

          There are many ways to do that

          If I may, but you didn't mention what any of them are. I too have been asking myself this question and I'm very interested to know what other people think.

          The difficult we do right away... ...the impossible takes slightly longer.

          G Offline
          G Offline
          geomeo123
          wrote on last edited by
          #4

          I don't think he knows. Think we might have to go to a university and earn a degree to figure it out.

          1 Reply Last reply
          0
          • G geomeo123

            I'm writing a program that allows users to send commands to various serial devices. Most of the commands are "Button" orientated. By that I mean they press a button and everything is done for them; however I have a textbox that allows them to type in manual commands should there be something I don't have a button for that they really want to happen. I'm thinking about logging what commands they are typing in order to improve my program so that I can add other buttons that will help make life easier all. I'm wondering if there's a way to do that possibly on Github so that I can retrieve basically over web. Or if there's a better way to do it? I'm currently working in Csharp/WPF. I'm also thinking about logging some try/catch handler errors, so that I can analyze software bugs too, but I'm not too bothered about that right now.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Have you looked into Log4net Tutorial for .NET Logging: 14 Best Practices and Examples[^]? It may not offer everything you want but is quite popular in the .NET world.

            R 1 Reply Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              jschell wrote:

              There are many ways to do that

              If I may, but you didn't mention what any of them are. I too have been asking myself this question and I'm very interested to know what other people think.

              The difficult we do right away... ...the impossible takes slightly longer.

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              Richard Andrew x64 wrote:

              but you didn't mention what any of them are.

              Some of them: To a SQL Database To a no-SQL Database To an event hub To flat files To a service that collects metrics. To a custom server API. To Syslog To Azure OpenAPI To AWS OpenSearch

              1 Reply Last reply
              0
              • L Lost User

                Have you looked into Log4net Tutorial for .NET Logging: 14 Best Practices and Examples[^]? It may not offer everything you want but is quite popular in the .NET world.

                R Offline
                R Offline
                Rob Philpott
                wrote on last edited by
                #7

                Ah, Log4Net. From the glory days of .NET, as I moved from (work) place to place everyone used it. Seems to have lost favour in the Core world, and been replaced by something more standardised and flexible, but not as to-the-point :( Two line logging, whoever thought that was a good idea?

                Regards, Rob Philpott.

                J 1 Reply Last reply
                0
                • R Rob Philpott

                  Ah, Log4Net. From the glory days of .NET, as I moved from (work) place to place everyone used it. Seems to have lost favour in the Core world, and been replaced by something more standardised and flexible, but not as to-the-point :( Two line logging, whoever thought that was a good idea?

                  Regards, Rob Philpott.

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #8

                  Rob Philpott wrote:

                  and been replaced by something more standardised and flexible,

                  What exactly?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups