تخصيص تسجيل iOS
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتم معالجة تسجيل الدخول إلى نظام التشغيل iOS من خلال IOSLogHandler.java،
والذي يلغي java.util.logging.Handler
. يمكنك ضبطه كإعداد تلقائي من خلال إضافة مرجع logging.properties
إلى
تطبيقك، كما هو موضّح في LogManager.
تغيير معالِج التسجيل آليًا
لإضافة معالج تسجيل آليًا، استخدم الرمز نفسه الذي تستخدمه لتغييره في Java:
LogManager.getLogger("").addHandler(myHandler);
إذا كنت لا تريد تشغيل المعالجات الحالية أيضًا، عليك إزالتها أولاً باستخدام:
Logger logger = LogManager.getLogger("");
for (Handler h : logger.getHandlers()) {
logger.removeHandler(h);
}
تغيير معالج التسجيل باستخدام ملف خاصية
لتغيير معالِج التسجيل التلقائي باستخدام ملف Log.properties، يجب تحديد ذلك المعالِج
هكذا (كما هو الحال مع تطبيقات Java):
handlers=mycompany.mylogger.MyIOSLogHandler
java.util.logging.ConsoleHandler.level=ALL
يمكن أن يكون لهذا الملف أي اسم، ما دام هذا الاسم مستخدَمًا أثناء التحميل.
بعد ذلك، أضِف الملف Log.properties كمورد لنظام التشغيل iOS إلى مشروعك.
على عكس تطبيقات Java، يحتاج تطبيق J2ObjC إلى تحميل ملف الخصائص بشكل صريح:
static {
// Fetch a logger in case the following leaves logging in a bad state, such
// as not adding the logging.properties resource or using a different name.
Logger log = Logger.getLogger("configLogger");
try {
InputStream loggingProperties = SomeClass.class.getResourceAsStream("logging.properties");
LogManager.getLogManager().readConfiguration(loggingProperties);
} catch (IOException exception) {
log.log(Level.SEVERE, "Error in loading configuration", exception);
}
}
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-08-28 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2024-08-28 (حسب التوقيت العالمي المتفَّق عليه)"],[[["iOS logging in J2ObjC applications uses a custom `IOSLogHandler` that overrides the standard Java logging handler."],["You can modify the logging behavior either programmatically by adding or removing handlers or by using a `logging.properties` file."],["To use a `logging.properties` file, you need to add it as an iOS resource and explicitly load it within your application code."],["When loading a custom `logging.properties` file, make sure to handle potential errors, such as missing files or incorrect configurations."]]],["iOS logging uses `IOSLogHandler.java`, which can be set as the default via a `logging.properties` resource. Programmatically, handlers are added using `LogManager.getLogger(\"\").addHandler(myHandler)`. Existing handlers can be removed with `logger.removeHandler(h)`. With a property file, specify the handler (e.g., `handlers=mycompany.mylogger.MyIOSLogHandler`) and add it as an iOS resource. The property file must be explicitly loaded in a J2ObjC app using `LogManager.getLogManager().readConfiguration(loggingProperties)`.\n"]]