Project 04

Simple Log Writer

This project implements a lightweight, reusable logging utility with a Windows Forms interface that writes timestamped log messages to a file with configurable log levels. The SimpleLogger class is designed to support comprehensive application diagnostics and auditing while emphasizing safe file access and reusability across multiple projects.

C# (.NET)

System.IO

Error Handling

Technical

Highlights

  • Created a reusable SimpleLogger class responsible for handling all log-writing concerns.

  • Implemented 6 configurable log levels (Trace, Debug, Info, Warning, Error, Critical) to support granular severity classification.

  • Implemented intelligent path handling that accepts both full file paths and directory paths, auto-generating timestamped filenames (Log(string, LogLevel)) when needed

  • Built a Windows Forms UI allowing users to:

    • Write custom log messages with user-selected severity levels

    • Generate predefined dummy messages for testing

    • Display log output in real-time via an integrated console

  • Used StreamWriter in append mode to ensure new log entries do not overwrite existing data.

  • Wrapped file operations in using() statements to guarantee proper stream disposal and avoid file locks.

  • Implemented thread-safe console writing using InvokeRequired pattern for cross-thread UI updates

  • Tested the logger within a Windows Forms application to validate repeated writes, custom messages, and real-world usage.

Project

Takeaways

  • Learned how to append log data safely while preserving existing log history.

  • Reinforced correct stream management patterns using using() for reliability and resource safety.

  • Developed a reusable utility component with a user-friendly interface intended for integration into future projects.

  • Developed smart path handling logic to improve user experience by accepting flexible input formats

  • Applied proper Windows Forms threading patterns to ensure safe UI updates.