Skip to content

Allow user to execute custom action on deprecated files (ex. move or send to different server) #106

Closed
@nogard111

Description

@nogard111

Can we allow different action on obsolete files ?
I think it would be beneficial in situation when old logs should be archived by moving to different folder or different server (dedicated only for logs)

/// Action that should be preformed on obsolete(old) log files
public static Action<string> OnObsoleteFile = null;

Inside remove loop:

          foreach (var obsolete in toRemove)
            {
                var fullPath = Path.Combine(_roller.LogFileDirectory, obsolete);
                try
                {
                    if(OnObsoleteFile!= null)
                        OnObsoleteFile.Invoke(fullPath);
                    else
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                catch (Exception ex)
                {
                    SelfLog.WriteLine("Error {0} while processing obsolete file {1}", ex, fullPath);
                }
            }

It is more like example, not working code :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions