tf.get_logger
Stay organized with collections
Save and categorize content based on your preferences.
Return TF logger instance.
tf.get_logger()
Used in the notebooks
Used in the guide |
Used in the tutorials |
|
|
Returns |
An instance of the Python logging library Logger.
|
See Python documentation (https://docs.python.org/3/library/logging.html)
for detailed API. Below is only a summary.
The logger has 5 levels of logging from the most serious to the least:
- FATAL
- ERROR
- WARN
- INFO
- DEBUG
The logger has the following methods, based on these logging levels:
- fatal(msg, *args, **kwargs)
- error(msg, *args, **kwargs)
- warn(msg, *args, **kwargs)
- info(msg, *args, **kwargs)
- debug(msg, *args, **kwargs)
The msg
can contain string formatting. An example of logging at the ERROR
level
using string formating is:
tf.get_logger().error("The value %d is invalid.", 3)
You can also specify the logging verbosity. In this case, the
WARN level log will not be emitted:
tf.get_logger().setLevel(ERROR)
tf.get_logger().warn("This is a warning.")
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.get_logger\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/platform/tf_logging.py#L93-L179) |\n\nReturn TF logger instance.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.get_logger`](https://www.tensorflow.org/api_docs/python/tf/get_logger)\n\n\u003cbr /\u003e\n\n tf.get_logger()\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Migrating your TFLite code to TF2](https://www.tensorflow.org/guide/migrate/tflite) - [Customizing MinDiffModel](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/customizing_min_diff_model) - [Integrating MinDiff with MinDiffModel](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/integrating_min_diff_with_min_diff_model) - [Integrating MinDiff without MinDiffModel](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/integrating_min_diff_without_min_diff_model) - [Subword tokenizers](https://www.tensorflow.org/text/guide/subwords_tokenizer) | - [TensorFlow Hub Object Detection Colab](https://www.tensorflow.org/hub/tutorials/tf2_object_detection) - [Implement Differential Privacy with TensorFlow Privacy](https://www.tensorflow.org/responsible_ai/privacy/tutorials/classification_privacy) - [Parametrized Quantum Circuits for Reinforcement Learning](https://www.tensorflow.org/quantum/tutorials/quantum_reinforcement_learning) - [Object Detection with TensorFlow Lite Model Maker](https://www.tensorflow.org/lite/models/modify/model_maker/object_detection) - [Text classification with TensorFlow Lite Model Maker](https://www.tensorflow.org/lite/models/modify/model_maker/text_classification) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An instance of the Python logging library Logger. ||\n\n\u003cbr /\u003e\n\nSee Python documentation (\u003chttps://docs.python.org/3/library/logging.html\u003e)\nfor detailed API. Below is only a summary.\n\nThe logger has 5 levels of logging from the most serious to the least:\n\n1. FATAL\n2. ERROR\n3. WARN\n4. INFO\n5. DEBUG\n\nThe logger has the following methods, based on these logging levels:\n\n1. fatal(msg, \\*args, \\*\\*kwargs)\n2. error(msg, \\*args, \\*\\*kwargs)\n3. warn(msg, \\*args, \\*\\*kwargs)\n4. info(msg, \\*args, \\*\\*kwargs)\n5. debug(msg, \\*args, \\*\\*kwargs)\n\nThe `msg` can contain string formatting. An example of logging at the `ERROR`\nlevel\nusing string formating is: \n\n tf.get_logger().error(\"The value %d is invalid.\", 3)\n\nYou can also specify the logging verbosity. In this case, the\nWARN level log will not be emitted: \n\n tf.get_logger().setLevel(ERROR)\n tf.get_logger().warn(\"This is a warning.\")"]]