Log4j - 仅将指定的方法记录到文件中(Log4j - Log only specified method to file)
使用log4j记录在属性文件中指定的特定事件(DEBUG,ERROR,FATAL ..)以仅记录DEBUG我仍然最终在文件中记录了其他错误消息。 有没有办法告诉log4j只将特定事件记录到文件中?
谢谢。
Using log4j to log specific events (DEBUG, ERROR, FATAL..) having specified in the properties file to log only DEBUG i still end up having other error messages logged in the file. Is there a way to tell log4j to log only specific events to a file?
Thank You.
原文:https://stackoverflow.com/questions/4387214
最满意答案
为此目的使用
NSUserDefault
,如下所示:要将整数保存到NSUserDefault,您可以使用以下代码:
NSUserDefaults.standardUserDefaults().setInteger(textField.text, forKey: "key")
要从保存的NSUserDefault获取值,请使用以下代码:
NSUserDefaults.standardUserDefaults().integerForKey("key")
编辑
要设置水龙头,请执行以下操作@IBAction func Button(sender: UIButton){ taps += 1 TapLabel.text = "Taps: \(taps)" NSUserDefaults.standardUserDefaults().setInteger(taps, forKey: "key") }
要获得点击,只需在
viewDidLoad
函数中执行此操作TapLabel.text = String(NSUserDefaults.standardUserDefaults().integerForKey("key"))
Use
NSUserDefault
for this purpose like this:To save an integer to a NSUserDefault you can use the following code:
NSUserDefaults.standardUserDefaults().setInteger(textField.text, forKey: "key")
To get the value from the saved NSUserDefault use the following code:
NSUserDefaults.standardUserDefaults().integerForKey("key")
Edit
To set the taps, do the following@IBAction func Button(sender: UIButton){ taps += 1 TapLabel.text = "Taps: \(taps)" NSUserDefaults.standardUserDefaults().setInteger(taps, forKey: "key") }
To get the taps, just do this in your
viewDidLoad
functionTapLabel.text = String(NSUserDefaults.standardUserDefaults().integerForKey("key"))
相关问答
更多-
如何在UWP中重新启动应用程序?(How to restart an app in UWP?)[2024-01-24]
根据最近的博客文章 ,有一个新的API“从Build 16226开始,以及相应的SDK。” 新的静态RequestRestartAsync(String)方法和CoreApplication上的重载提供了以前不可用的应用程序重启魔术,包括将参数传递给新实例的能力。 According to a recent blog post, there is a new API for this "from Build 16226 onwards, along with the corresponding SDK." ... -
重新启动我的Python脚本(Restart my Python script)[2023-04-19]
解 你的代码有几个错误。 最常见的是你正在使用递归作为循环构造。 不要这样做。 这是一个介绍bug的好方法,更不用说你的“循环”运行多次,你会达到递归限制。 只需使用while循环: def run_game(self): while True: answer = input() if answer.isdigit(): n = int(answer) if n > int(self.rand): ... -
错误定义明确,你应该知道你哪里出错了。 这是部门的数量。 The error is well defined, and you should get an idea of where you are getting wrong. ITs the number of sections.
-
还有“ Microsoft Azure管理库 ”Nuget,它允许您从应用程序内部使用Azure服务。 有关如何从Azure网站内部创建新网站的示例,请参阅此页面 。 重新启动Web服务的工作方式与创建新服务的方式类似。 有关可用网站相关方法的列表,请参阅此页面 。 此外,对于使用证书基本身份验证进行身份验证,请参阅此页面以获取更多详细信息。 Bellow是一个简短的命令行程序,它将重新启动Azure订阅中的所有网站空间中的所有网站。 它有点像Azure网站的iisreset。 该代码基于前面提到的链接中的 ...
-
在swift4中保存label.text(Save label.text in swift4)[2023-08-19]
您可以将其保存在UserDefaults 。 @IBAction func stepper_montageplatte(_ sender: UIStepper) { lbl_montageplatte.text = Int(sender.value).description UserDefaults.standard.set(String(sender.value), forKey: "lblMontageplatte") } 为了回报价值,你可以做如下... if let lblVal ... -
从API 19开始,警报传递不准确(参见文档 )。 除此之外,为什么要在停止时重新启动应用程序? 这听起来不对...... Starting from API 19, alarm delivery is inexact (see docs). Outside of that, why do you want to restart your app if it is stopped? That doesn't sound right ....
-
不是,而是允许您的应用在购买某些东西时自行改变。 调用需要更改其内容的对象的方法,以便可以通知状态更改并更改其内部以符合。 有时候,如果看起来没有办法做你想做的事,那么有一个更好的办法。 No. Instead allow your app to alter itself when something has been purchased. Call a method on the objects that need to have their content changed so they can be ...
-
为此目的使用NSUserDefault ,如下所示: 要将整数保存到NSUserDefault,您可以使用以下代码: NSUserDefaults.standardUserDefaults().setInteger(textField.text, forKey: "key") 要从保存的NSUserDefault获取值,请使用以下代码: NSUserDefaults.standardUserDefaults().integerForKey("key") 编辑 要设置水龙头,请执行以下操作 @IBActi ...
-
这可能有所帮助: #!/bin/bash TMP_FILE="/tmp/currentLineNumber" # a constant current_line_count=0 # track the current line number processed_lines_count=0 # Verify if we have already processed some stu ...
-
如果使用第三方库不适合您的项目,我强烈建议您使用Akavache 。 这是一个异步,持久的键值存储。 一旦设置非常简单易用。 //插入对象 IObservable
InsertObject (string key, T value, DateTimeOffset? absoluteExpiration = null); //获取您的对象 IObservable GetObject (string key); 其中T可以是你的整个清单。 当然它比这更多但是相信我一点点。 阅读完整 ...