# mickdelaney/log4net.rabbitmq architecture

> Architecture diagram of the GitHub repository mickdelaney/log4net.rabbitmq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mickdelaney/log4net.rabbitmq
- Repository: https://github.com/mickdelaney/log4net.rabbitmq

## Overview

##### Main Components

a) Core Components:
- log4net Application Integration
- RabbitMQAppender
- RabbitMQ Message Broker
- Log Consumers/Subscribers

b) Supporting Components:
- Configuration System
- Message Formatting Layer
- Connection Management
- Authentication/Security Layer

**[Application Using log4net] --> [log4net Core] --> [RabbitMQAppender] --> [RabbitMQ Broker] --> [Log Consumers]**

##### Detailed Component Breakdown

a) RabbitMQAppender Component (Central Focus):
- Internal structure with:
- Configuration Handler (for VHost, Username, Password, etc.)
- Message Formatter (Layout Pattern Conversion)
- Connection Manager
- Topic Publisher
- Extended Data Processor (for optional metadata)

b) Integration Points:
- How it implements log4net's appender interface
- Demonstrate message flow from application to RabbitMQ

##### Important Details

a) Configuration Elements:
- Configuration properties (VHost, UserName, Password, Port, etc.)
- Topic pattern mechanism
- Exchange configuration

b) Message Properties:
- Standard properties (ContentEncoding, ContentType, AppId, Timestamp)
- Optional ExtendedData headers

##### Technical Specifications to Note

- Protocol support
- SSL capability
- Authentication mechanisms
- Exchange and queue declarations

##### Implementation Notes

- Normal operation flow
- Error handling paths
- Configuration reload scenarios
- Connection management

##### Top Level
**[Application] --> [log4net Core] --> [RabbitMQAppender] --> [RabbitMQ Broker]**

- [Configuration]

##### RabbitMQAppender Detail
**[Message Receiver] --> [Layout Formatter] --> [Topic Publisher]**

- v                    v                      v
**[Property Handler] --> [Extended Data] --> [Connection Manager]**

##### Consumer Side
**[RabbitMQ Broker] --> [Queue Binding] --> [Consumers]**

Remember to:
- Clear boundaries between components
- Notes for important configuration details
- Both synchronous and asynchronous paths

This design should capture the essence of the logging system while showing the important architectural decisions and integration points that make it work effectively with both log4net and RabbitMQ.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Application
        App[Application Using log4net]:::application
        Config["Configuration System"]:::config
    end

    subgraph Logging
        Log4net[log4net Core]:::logging
    end

    subgraph RabbitMQAppender
        Appender["RabbitMQAppender"]:::core
        MsgFormat["Message Formatter"]:::component
        ConnMgr["Connection Manager"]:::component
        PropHandler["Property Handler"]:::component
        ExtData["Extended Data Processor"]:::component
        TopicPub["Topic Publisher"]:::component
    end

    subgraph Messaging
        RMQ[("RabbitMQ Broker")]:::broker
        Exchange["Exchange"]:::broker
        Queue["Queue Binding"]:::broker
    end

    subgraph Consumers
        LogConsumers["Log Consumers"]:::consumer
    end

    %% Connections
    App --> |"Logging Calls"| Log4net
    Config -.-> |"Configure"| Appender
    Log4net --> |"Forward Logs"| Appender
    
    %% RabbitMQAppender Internal Flow
    Appender --> MsgFormat
    Appender --> PropHandler
    MsgFormat --> TopicPub
    PropHandler --> ExtData
    ExtData --> TopicPub
    ConnMgr --> TopicPub
    
    %% Message Flow to RabbitMQ
    TopicPub --> Exchange
    Exchange --> Queue
    Queue --> LogConsumers

    %% Styling
    classDef application fill:#f9f,stroke:#333,stroke-width:2px
    classDef config fill:#ff9,stroke:#333,stroke-width:2px
    classDef logging fill:#9cf,stroke:#333,stroke-width:2px
    classDef core fill:#f96,stroke:#333,stroke-width:2px
    classDef component fill:#fff,stroke:#333,stroke-width:1px
    classDef broker fill:#9f9,stroke:#333,stroke-width:2px
    classDef consumer fill:#ccc,stroke:#333,stroke-width:2px

    %% Click Events
    click Appender "https://github.com/mickdelaney/log4net.RabbitMQ/blob/develop/src/log4net.RabbitMQ/RabbitMQAppender.cs"
    click Config "https://github.com/mickdelaney/log4net.RabbitMQ/blob/develop/src/samples/log4net.RabbitMQ.SampleWeb/log4net.config"
    click LogConsumers "https://github.com/mickdelaney/log4net.RabbitMQ/blob/develop/src/samples/log4net.RabbitMQ.Listener/Program.cs"
    click App "https://github.com/mickdelaney/log4net.RabbitMQ/tree/develop/src/samples/log4net.RabbitMQ.SampleWeb/"
    click Log4net "https://github.com/mickdelaney/log4net.RabbitMQ/tree/develop/src/packages/log4net.1.2.10/"
    click RMQ "https://github.com/mickdelaney/log4net.RabbitMQ/tree/develop/src/packages/RabbitMQ.Client.2.5.1/"

    %% Legend
    subgraph Legend
        L1[Application Components]:::application
        L2[Configuration]:::config
        L3[Logging Components]:::logging
        L4[Core Components]:::core
        L5[Internal Components]:::component
        L6[Broker Components]:::broker
        L7[Consumer Components]:::consumer
    end
```
