本文整理汇总了C#中log4net.ILog.Error方法的典型用法代码示例。如果您正苦于以下问题:C# log4net.ILog.Error方法的具体用法?C# log4net.ILog.Error怎么用?C# log4net.ILog.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4net.ILog
的用法示例。
在下文中一共展示了log4net.ILog.Error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnException
protected override void OnException(ExceptionContext filterContext)
{
//Log error
logger = log4net.LogManager.GetLogger(filterContext.Controller.ToString());
logger.Error(filterContext.Exception.Message, filterContext.Exception);
}
示例2: OnStart
protected override void OnStart(string[] args)
{
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(baseDir + "log4net.xml"));
log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try
{
// Pick one
//RemotingConfiguration.CustomErrorsEnabled(false);
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
//RemotingConfiguration.Configure(baseDir + "RrdbFileService.exe.config");
log.Info("RrdDb file server started");
var nameValueCollection = (NameValueCollection)ConfigurationManager.GetSection("rrdbfileserver");
log.InfoFormat("Database file base path:{0}", nameValueCollection["databasepath"]);
string port = nameValueCollection["port"];
int portNumber = int.Parse(port);
channel = new TcpChannel(portNumber);
ChannelServices.RegisterChannel(channel, false);
log.InfoFormat("Server object registerd on port {0}", portNumber);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RrdDbAdapter),
"GetRrdDbAdapter",
WellKnownObjectMode.Singleton);
log.Info("Service up and running");
}
catch (Exception ex)
{
log.Error(ex);
throw;
}
}
示例3: WriteLog
public void WriteLog(LogEnum name, LogLevel level, string logContent)
{
log = log4net.LogManager.GetLogger(name.ToString());
//log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
switch (level)
{
case LogLevel.DEBUG:
log.Debug(logContent);
break;
case LogLevel.ERROR:
log.Error(logContent);
break;
case LogLevel.FATAL:
log.Fatal(logContent);
break;
case LogLevel.INFO:
log.Info(logContent);
break;
case LogLevel.WARN:
log.Warn(logContent);
break;
default:
log.Debug(logContent);
break;
}
}
示例4: clg_ServeurTCPSQLSever
public clg_ServeurTCPSQLSever(string pServeur, int pPortEcouteServBD, CLG_AccesBD.clg_Connecteur pCnn, log4net.ILog pLoggeur)
: base(pServeur, pPortEcouteServBD)
{
try {
c_Loggeur = pLoggeur;
c_Connecteur = pCnn;
c_AdresseServSynchro = pServeur;
c_PortServSynchro = pPortEcouteServBD;
c_ConnexionsTCP = new Dictionary<string, clg_CnnServeurTCPSQLServer>();
c_Cnn = new CLG_AccesBD.clg_Connection(ref c_Connecteur);
c_Cnn.Ouvre();
} catch (Exception ex) {
c_Loggeur.Error("Erreur a l'instanciation de la classe ServeurTCPSQLServer : " + ex.Message);
}
}
示例5: Client
/// <summary>
/// Initialize a new Minecraft client.
/// </summary>
/// <param name="server">The server to connect to.</param>
/// <param name="player">The player who logged in with the client.</param>
public Client(Server server, Player player)
{
_log = LogManager.GetLogger(this);
_log.Debug("Minecraft Client created!");
_server = server;
_log.Debug("Loading Items from file...");
try
{
using (var reader = new StreamReader(Constants.MinecraftItemFile))
Items = new JsonSerializer().Deserialize<List<Item>>(new JsonTextReader(reader));
}
catch(IOException ex)
{
_log.Error("Failed to read item list from file!");
_log.Error(ex.GetType() + ": " + ex.Message);
_log.Error("Stack Trace:\n" + ex.StackTrace);
throw new Exception("Sharpcraft.Library.Minecraft.Client failed to initialize! Could not read item list file!", ex);
}
_log.Debug("Creating communication protocol...");
_protocol = new Protocol(_server.Address, _server.Port);
_log.Info("Client initiated on " + _server.Address + ":" + _server.Port + "!");
_player = player;
_world = new World();
}
示例6: Start
//.........这里部分代码省略.........
helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-US.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t[filename]");
helpOutput.AppendLine("\t\tOpen the bitmap files in the running Greenshot instance or start a new instance");
Console.WriteLine(helpOutput.ToString());
// If attach didn't work, wait for key otherwise the console will close to quickly
if (!attachedToConsole)
{
Console.ReadKey();
}
FreeMutex();
return;
}
if (argument.ToLower().Equals("/exit"))
{
// unregister application on uninstall (allow uninstall)
try
{
LOG.Info("Sending all instances the exit command.");
// Pass Exit to running instance, if any
SendData(new CopyDataTransport(CommandEnum.Exit));
}
catch (Exception e)
{
LOG.Warn("Exception by exit.", e);
}
FreeMutex();
return;
}
// Reload the configuration
if (argument.ToLower().Equals("/reload"))
{
// Modify configuration
LOG.Info("Reloading configuration!");
// Update running instances
SendData(new CopyDataTransport(CommandEnum.ReloadConfig));
FreeMutex();
return;
}
// Stop running
if (argument.ToLower().Equals("/norun"))
{
// Make an exit possible
FreeMutex();
return;
}
// Language
if (argument.ToLower().Equals("/language"))
{
conf.Language = args[++argumentNr];
IniConfig.Save();
continue;
}
// Files to open
filesToOpen.Add(argument);
}
// Finished parsing the command line arguments, see if we need to do anything
CopyDataTransport transport = new CopyDataTransport();
if (filesToOpen.Count > 0)
{
foreach (string fileToOpen in filesToOpen)
{
transport.AddCommand(CommandEnum.OpenFile, fileToOpen);
}
}
if (MainForm.instance == null)
MainForm.instance = new MainForm(transport);
// if language is not set, show language dialog
if (string.IsNullOrEmpty(conf.Language))
{
LanguageDialog languageDialog = LanguageDialog.GetInstance();
languageDialog.ShowDialog();
conf.Language = languageDialog.SelectedLanguage;
IniConfig.Save();
}
// Check if it's the first time launch?
if (conf.IsFirstLaunch)
{
conf.IsFirstLaunch = false;
IniConfig.Save();
transport.AddCommand(CommandEnum.FirstLaunch);
}
}
catch (Exception ex)
{
LOG.Error("Exception in startup.", ex);
Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
}
}
示例7: IceManager
public IceManager(string adapterName, string host, int port, bool catchSignals = true)
{
IceGridHost = host;
IceGridPort = port;
Name = adapterName;
logger = log4net.LogManager.GetLogger(this.GetType().Name + "::" + Name);
_ServantIds = new List<Ice.Identity>(); //keep track of servants for emergency cleanup
string myIP = findLocalIPAddress();
logger.Info("My IPAddress is: " + myIP);
//initialize Ice
Ice.Properties prop = Ice.Util.createProperties();
prop.setProperty("hms.AdapterId", adapterName);
prop.setProperty("hms.Endpoints", "tcp -h " + myIP + ":udp -h " + myIP);
prop.setProperty("Ice.Default.Locator", "IceGrid/Locator:tcp -p " + IceGridPort + " -h " + IceGridHost);
prop.setProperty("Ice.ThreadPool.Server.Size", "5");
prop.setProperty("Ice.ThreadPool.Server.SizeMax", "100000");
prop.setProperty("Ice.ThreadPool.Client.Size", "5");
prop.setProperty("Ice.ThreadPool.Client.SizeMax", "100000");
Ice.InitializationData iceidata = new Ice.InitializationData();
iceidata.properties = prop;
Communicator = Ice.Util.initialize(iceidata); // could add sys.argv
try
{
_Adapter = Communicator.createObjectAdapter("hms");
_Adapter.activate();
}
catch (Exception ex)
{
logger.Fatal("Network error, check configuration: " + ex.Message);
logger.Fatal("Endpoint(should be local machine): " + prop.getProperty("hms.Endpoints"));
logger.Fatal("Locator (should be IceGrid Server): " + prop.getProperty("Ice.Default.Locator"));
throw (ex); // we are dead anyway
}
//Now are we ready to communicate with others
//getting usefull proxies
try
{
// proxy to icegrid to register our vc devices
Query = IceGrid.QueryPrxHelper.checkedCast(Communicator.stringToProxy("IceGrid/Query"));
if (Query == null)
{
logger.Error("invalid ICeGrid proxy");
}
// proxy to icestorm to publish events
EventMgr = IceStorm.TopicManagerPrxHelper.checkedCast(Communicator.stringToProxy("EventServer/TopicManager"));
if (EventMgr == null)
{
logger.Error("invalid IceStorm proxy");
}
//these 2 objects are only needed to get the IceGrid admin object in order to register
_Registry = IceGrid.RegistryPrxHelper.uncheckedCast(Communicator.stringToProxy("IceGrid/Registry"));
updateIceGridAdmin();
}
catch (Ice.NotRegisteredException e)
{
logger.Fatal("If we fail here it is probably because the Icebox objects are not registered: " + e.Message);
}
catch (Exception e)
{
logger.Fatal("IceGrid Server not found!!!!!: " + e.Message);
throw (e);//without yellow page system, there is no need to start
}
if (catchSignals)
{
setupSignals();
}
}
示例8: MainGame
public MainGame()
{
_log = LogManager.GetLogger(this);
Activated += GameActivated;
Deactivated += GameDeactivated;
_log.Debug("Setting initial FPS value");
FPS = 0.0f;
_log.Info("Setting graphics settings...");
_graphics = new GraphicsDeviceManager(this)
{
PreferredBackBufferWidth = ScreenWidth,
PreferredBackBufferHeight = ScreenHeight
};
_log.Info(string.Format("Screen size set to: [W]{0} x [H]{1}", ScreenWidth, ScreenHeight));
_graphics.SynchronizeWithVerticalRetrace = false;
//IsFixedTimeStep = false;
_graphics.ApplyChanges();
ScreenRectangle = new Rectangle(0, 0, ScreenWidth, ScreenHeight);
_log.Debug("Setting content root directory...");
Content.RootDirectory = "Content";
// Create necessary folders if they don't exist
try
{
if (!Directory.Exists(Paths.SettingsFolder))
Directory.CreateDirectory(Paths.SettingsFolder);
}
catch (IOException ex)
{
_log.Error("Failed to create necessary game folders. Exception details as follows...");
_log.Fatal("IOException: " + ex.Message + Environment.NewLine + "Details:", ex);
_log.Fatal("Game will now exit...");
Exit();
}
_log.Info("Loading controls...");
ControlsManager = new ControlsManager();
_log.Debug("Controls loaded!");
_log.Info("Creating components...");
AudioManager = new AudioManager();
_stateManager = new GameStateManager(this);
TitleScreen = new TitleScreen(this, _stateManager);
StartMenuScreen = new StartMenuScreen(this, _stateManager);
CharacterGeneratorScreen = new CharacterGeneratorScreen(this, _stateManager);
SkillScreen = new SkillScreen(this, _stateManager);
LoadGameScreen = new LoadGameScreen(this, _stateManager);
GamePlayScreen = new GamePlayScreen(this, _stateManager);
Components.Add(new InputHandler(this));
Components.Add(_stateManager);
_log.Info("Components created!");
LoadMusic();
var menuSong = AudioManager.Song.GetSong("MenuTheme");
menuSong.SetStartFade(new FadeInfo(0.0f, 1.0f, 0.01f, TimeSpan.FromMilliseconds(20)));
menuSong.SetEndFade(new FadeInfo(1.0f, 0.0f, 0.01f, TimeSpan.FromMilliseconds(15)));
_log.Debug("Changing to TitleScreen...");
_stateManager.ChangeState(TitleScreen);
}
示例9: Main
static void Main()
{
bool ok;
// Only allow one instance of the switcher to start
exclusiveAppMtx = new System.Threading.Mutex(true, "{D39FAB11-ED23-478d-AF57-C638F79A7BA8}", out ok);
if (!ok)
{
return;
}
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Assembly.GetExecutingAssembly().Location + ".config"));
log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log.Info("Application Started");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
Application.ApplicationExit += Application_ApplicationExit;
monitor.RegChanged += new EventHandler(OnRegChanged);
monitor.Error += new System.IO.ErrorEventHandler(OnRegMonError);
try
{
log.Info("Starting plugin...");
//Populate notifications from XML file
_assembly = Assembly.GetExecutingAssembly();
alertReader = new StreamReader(_assembly.GetManifestResourceStream(Resources.ResourceManager.GetString("strings.xml")));
XmlSerializer deserializer = new XmlSerializer(typeof(List<Alert>));
TextReader textReader = alertReader;
alertList = (List<Alert>)deserializer.Deserialize(textReader);
textReader.Close();
}
catch (Exception ex)
{
log.Error(ex.ToString());
MessageBox.Show(Resources.ResourceManager.GetString("Error loading"));
}
if (SetupPlugin())
{
OnRegChanged(null, EventArgs.Empty);
_systray = new TrayIcon();
Application.Run();
}
}
示例10: Init
/// <summary>
/// Initializes the <c>SteamManager</c>.
/// This MUST be called before other Steam operations are executed.
/// </summary>
/// <returns><c>true</c> if everything initialized properly, <c>false</c> otherwise.</returns>
public static bool Init()
{
if (Enabled)
{
_log.Warn("Tried to call Init method when SteamManager has already been initialized! Aborting...");
return false;
}
_log = LogManager.GetLogger(typeof(SteamManager));
try
{
if (!Steamworks.Load())
{
_log.Error("Steamworks failed to load, throwing exception!");
throw new SteamException("Steamworks failed to load.", SteamExceptionType.SteamworksLoadFail);
}
Client = Steamworks.CreateInterface<ISteamClient010>("SteamClient010");
if (Client == null)
{
_log.Error("Steamclient is NULL!! Throwing exception!");
throw new SteamException("Steamclient failed to load! Is the client running? (Sharpcraft.Steam.SteamManager.Client == null!)",
SteamExceptionType.SteamLoadFail);
}
Pipe = Client.CreateSteamPipe();
User = Client.ConnectToGlobalUser(Pipe);
Friends = Steamworks.CastInterface<ISteamFriends002>(Client.GetISteamFriends(User, Pipe, "SteamFriends002"));
if (Friends == null)
return false;
FriendList = new SteamFriendList();
_steamWatcher = new Timer(SteamCheck, null, 0, 1000);
}
catch (SteamException ex)
{
_log.Warn("Warning! SteamManager caught a SteamException exception, returning FALSE. Steam components will NOT LOAD!");
_log.Warn("The SteamException type was: " + System.Enum.GetName(typeof(SteamExceptionType), ex.Type));
return false;
}
_log.Info("SteamManager has been initialized!");
SteamLoaded = true;
Enabled = true;
return true;
}