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. Visual Basic
  4. Log File

Log File

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 4 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.
  • L Offline
    L Offline
    LordLothar
    wrote on last edited by
    #1

    How can i implement a log file which record my application activity.

    C L R 3 Replies Last reply
    0
    • L LordLothar

      How can i implement a log file which record my application activity.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I'm not sure if there's any automatic way, but I use a class of static logging methods and a lazy initialised file stream which is closed in IDispose. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • L LordLothar

        How can i implement a log file which record my application activity.

        L Offline
        L Offline
        Len Miller
        wrote on last edited by
        #3

        If you want to write to an O/S filesystem (text) file - see help on file streams and text files (I assume you do not need this). See System.IO namespace. To log to the windows event log (I assume this is what you want something like this): Private Shared Sub WriteToAppLog( _ ByVal message As String _ , ByVal messageType As EventLogEntryType _ ) Dim elLog As System.Diagnostics.EventLog Try elLog = New System.Diagnostics.EventLog( _ "Application" _ , Environment.MachineName _ , Application.ProductName _ ) elLog.WriteEntry(message, messageType) Catch ex As Exception 'Your error handling here End Try End Sub I suggest you write a reusable application-message class handling messages to user/screen, text log file or Windows Event log (or any combination there in). Use designation before your enum declaration to "OR" these options together in a bitwise fashion. Good luck, -Len Thanks, -Len Miller "If I had eight hours to chop down a tree, I'd spend six sharpening my axe." -Abraham Lincoln

        1 Reply Last reply
        0
        • L LordLothar

          How can i implement a log file which record my application activity.

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          A basic implementation for this is already provided in the framework. The TraceListener class might be a good start for reading. If you need something more sophisticated you should have a look at NLog. This article describes the basics for using it.

          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