Reputation: 27
I have references object
which contains abstract LoggerFile
class. I am trying to access it. But it is showing inaccessible due to protection
level. Please anyone help me to understand it.
abstract class LoggerFile
{
private static String logFile = null;
/// <summary>
/// Logfile Property
/// </summary>
public static string LogFile { get => logFile; set => logFile = value; }
/// <summary>
/// Set logFile
/// </summary>
/// <param name="logFile">The absolute path to file for writting logs</param>
public static void SetLogFile(String logFile)
{
LogFile = LogFile ?? logFile;
if (!File.Exists(LogFile))
{
File.Create(LogFile).Close();
}
}
}
}
I am calling this in another class.
using DriverAutomation.Loggin[enter image description here][1]g;
public class Devcon
{
private static Devcon devcon = null;
private readonly String devconEXE;
private readonly String devconPath;
private readonly String devconExeName;
private readonly Logger logger;
/// <summary>
/// DevconStatus Property for devcon status outcome backup
/// </summary>
public readonly String devconStatus;
/// <summary>
/// Initializes the Devcon Singleton Instance
/// </summary>
private Devcon()
{
devcon = this;
logger = Logger.GetLogger(GetType().Name, LoggerFile.LogFile);
devconExeName = "devcon.exe";
devconEXE = Path.Combine(Directory.GetCurrentDirectory(), devconExeName);
}
}
This is working within created solution. But using reference object it is showing error. Please find image.
Upvotes: 1
Views: 908
Reputation: 26450
Declare your class as public and non-Abstract and I think it will solve your problem.
public class LoggerFile
By the way, why is it even Abstract
. If you only have some static members in it, maybe you should just turn it to static itself.
Though in most logger implementations, it makes sense to follow the singleton pattern (one of the few cases)
Upvotes: 3